Skip to content

Commit db3fb6a

Browse files
committed
Bugfix: avoid null pointer exceptions on DownloadDao due to 'result' being null.
1 parent e05a50f commit db3fb6a

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/main/java/cloudgene/mapred/database/dao/DownloadDao.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public Download findByHash(String hash) {
8686

8787
try {
8888
Download result = queryForObject(sql, params, new DownloadMapper());
89-
log.debug("find download by hash {} successful. name: {}", hash, result.getName());
89+
log.debug("find download by hash {} successful. result: {}",
90+
hash, (result == null) ? null : result.getName());
9091
return result;
9192
} catch (SQLException e) {
9293
log.error("find download by hash {} failed.", hash, e);
@@ -102,7 +103,8 @@ public Download findByJobAndPath(String job, String path) {
102103

103104
try {
104105
Download result = queryForObject(sql, params, new DownloadMapper());
105-
log.debug("find download by job {} and path {} successful. name: {}", job, path, result.getName());
106+
log.debug("find download by job {} and path {} successful. result: {}",
107+
job, path, (result == null) ? null : result.getName());
106108
return result;
107109
} catch (SQLException e) {
108110
log.error("find download by job {} and path {} failed.", job, path, e);
@@ -119,8 +121,8 @@ public Download findByParameterAndName(CloudgeneParameterOutput param, String fi
119121

120122
try {
121123
Download result = queryForObject(sql, params, new DownloadMapper());
122-
log.debug("find download by param {} and filename {} successful. name: {}",
123-
param.getId(), filename, result.getName());
124+
log.debug("find download by param {} and filename {} successful. result: {}",
125+
param.getId(), filename, (result == null) ? null : result.getName());
124126
return result;
125127
} catch (SQLException e) {
126128
log.error("find download by param {} and filename {} failed.", param.getId(), filename, e);

src/test/java/cloudgene/mapred/api/v2/jobs/DownloadResultsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class DownloadResultsTest {
2424
CloudgeneClientRestAssured client;
2525

2626
@Test
27-
public void testDownloadSingleFile() throws InterruptedException {
27+
public void testDownloadSingleFile() {
2828
Header accessToken = client.loginAsPublicUser();
2929

3030
// submit job
@@ -87,7 +87,7 @@ public void testDownloadSingleFile() throws InterruptedException {
8787
}
8888

8989
@Test
90-
public void testDownloadSingleFolder() throws InterruptedException {
90+
public void testDownloadSingleFolder() {
9191
Header accessToken = client.loginAsPublicUser();
9292

9393
// submit job
@@ -138,7 +138,7 @@ public void testDownloadSingleFolder() throws InterruptedException {
138138
}
139139

140140
@Test
141-
public void testDownloadCounter() throws InterruptedException {
141+
public void testDownloadCounter() {
142142
Header accessToken = client.loginAsPublicUser();
143143

144144
// submit job

0 commit comments

Comments
 (0)