Skip to content

Commit f5ec0a6

Browse files
authored
fix more strict mode violation (#6937)
#no-changelog
1 parent 0a880cc commit f5ec0a6

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/CommonUtils.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ static Architecture getValue() {
139139
public static String streamToString(InputStream is) {
140140
// Previous code was running into this: http://code.google.com/p/android/issues/detail?id=14562
141141
// on Android 2.3.3. The below code below does not exhibit that problem.
142-
final java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
143-
return s.hasNext() ? s.next() : "";
142+
try (final java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A")) {
143+
return s.hasNext() ? s.next() : "";
144+
}
144145
}
145146

146147
public static String sha1(String source) {

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/CrashlyticsController.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -661,15 +661,15 @@ private InputStream getResourceAsStream(String resource) {
661661
}
662662

663663
private static byte[] readResource(InputStream is) throws IOException {
664-
ByteArrayOutputStream out = new ByteArrayOutputStream();
665-
byte[] buffer = new byte[1024];
666-
int length;
664+
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
665+
byte[] buffer = new byte[1024];
666+
int length;
667667

668-
while ((length = is.read(buffer)) != -1) {
669-
out.write(buffer, 0, length);
668+
while ((length = is.read(buffer)) != -1) {
669+
out.write(buffer, 0, length);
670+
}
671+
return out.toByteArray();
670672
}
671-
672-
return out.toByteArray();
673673
}
674674

675675
private void finalizePreviousNativeSession(String previousSessionId) {

0 commit comments

Comments
 (0)