Skip to content

Commit 6c16f65

Browse files
committed
Utilize mark and reset for stream handling
1 parent b122cef commit 6c16f65

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

bundles/org.eclipse.swt.svg/src/org/eclipse/swt/svg/JSVGRasterizer.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@ public boolean isSVGFile(InputStream stream) throws IOException {
165165
if (stream == null) {
166166
throw new IllegalArgumentException("InputStream cannot be null");
167167
}
168-
int firstByte = inputStream.read();
169-
return firstByte == '<';
168+
stream.mark(Integer.MAX_VALUE);
169+
try {
170+
int firstByte = stream.read();
171+
return firstByte == '<';
172+
} finally {
173+
stream.reset();
174+
}
170175
}
171176
}

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/SVGRasterizer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public interface SVGRasterizer {
3737
/**
3838
* Determines whether the given {@link InputStream} contains a SVG file.
3939
*
40-
* @param inputStream the input stream to check.
40+
* @param stream the input stream to check.
4141
* @return {@code true} if the input stream contains SVG content; {@code false}
4242
* otherwise.
4343
* @throws IOException if an error occurs while reading the stream.

0 commit comments

Comments
 (0)