Skip to content

Commit f2b8fba

Browse files
authored
fix rss service null pointer exception (#200)
1 parent 479ae6e commit f2b8fba

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/main/java/run/ikaros/server/service/RssServiceImpl.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,25 @@ public String downloadRssXmlFile(@Nonnull String url) {
144144
bufferedOutputStream.write(buffer, 0, len);
145145
}
146146
LOGGER.info("download rss xml file to cache path: {}", cacheFilePath);
147-
} catch (IOException e) {
147+
} catch (Exception e) {
148148
String msg = "fail write rss url xml file bytes to cache path: " + cacheFilePath;
149149
LOGGER.warn(msg, e);
150150
throw new RssOperateException(msg, e);
151151
} finally {
152152
try {
153-
bufferedOutputStream.close();
154-
outputStream.close();
155-
bufferedInputStream.close();
156-
inputStream.close();
157-
} catch (IOException e) {
153+
if (bufferedOutputStream != null) {
154+
bufferedOutputStream.close();
155+
}
156+
if (outputStream != null) {
157+
outputStream.close();
158+
}
159+
if (bufferedInputStream != null) {
160+
bufferedInputStream.close();
161+
}
162+
if (inputStream != null) {
163+
inputStream.close();
164+
}
165+
} catch (Exception e) {
158166
throw new RssOperateException(e);
159167
}
160168
}

0 commit comments

Comments
 (0)