Skip to content
Permalink
Browse files
8263560: Remove needless wrapping with BufferedInputStream
Reviewed-by: prr, alanb, dfuchs, serb
  • Loading branch information
stsypanov authored and shipilev committed Mar 30, 2021
1 parent 182b11c commit 1a681fa743d248f9096e06d596f5eba393113ce2
Showing with 7 additions and 10 deletions.
  1. +5 −5 src/java.base/share/classes/jdk/internal/jmod/JmodFile.java
  2. +2 −5 src/java.desktop/share/classes/sun/awt/image/ByteArrayImageSource.java
@@ -25,7 +25,6 @@

package jdk.internal.jmod;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -52,11 +51,12 @@
};

public static void checkMagic(Path file) throws IOException {
try (InputStream in = Files.newInputStream(file);
BufferedInputStream bis = new BufferedInputStream(in)) {
try (InputStream in = Files.newInputStream(file)) {
// validate the header
byte[] magic = new byte[4];
bis.read(magic);
byte[] magic = in.readNBytes(4);
if (magic.length != 4) {
throw new IOException("Invalid JMOD file: " + file);
}
if (magic[0] != JMOD_MAGIC_NUMBER[0] ||
magic[1] != JMOD_MAGIC_NUMBER[1]) {
throw new IOException("Invalid JMOD file: " + file.toString());
@@ -27,7 +27,6 @@

import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.BufferedInputStream;

public class ByteArrayImageSource extends InputStreamImageSource {
byte[] imagedata;
@@ -52,10 +51,8 @@ final boolean checkSecurity(Object context, boolean quiet) {
}

protected ImageDecoder getDecoder() {
InputStream is =
new BufferedInputStream(new ByteArrayInputStream(imagedata,
imageoffset,
imagelength));
InputStream is = new ByteArrayInputStream(imagedata, imageoffset,
imagelength);
return getDecoder(is);
}
}

1 comment on commit 1a681fa

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 1a681fa Mar 30, 2021

Please sign in to comment.