Why this matters
The default implementation of `read(byte[], int, int)` calls `read()` for every byte, leading to poor performance. Overriding this method improves efficiency.
Ensure that the `read(byte[], int, int)` method is overridden in `InputStream` subclasses to improve efficiency.
The default implementation of `read(byte[], int, int)` calls `read()` for every byte, leading to poor performance. Overriding this method improves efficiency.
Side-by-side examples engineers can pattern-match during review.
public class MyInputStream extends java.io.InputStream {
private FileInputStream fin;
public MyInputStream(File file) throws IOException {
fin = new FileInputStream(file);
}
@Override
public int read() throws IOException {
return fin.read();
}
}public class MyInputStream extends java.io.InputStream {
private FileInputStream fin;
public MyInputStream(File file) throws IOException {
fin = new FileInputStream(file);
}
@Override
public int read() throws IOException {
return fin.read();
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
return fin.read(b, off, len);
}
}public class MyInputStream extends java.io.InputStream {
private FileInputStream fin;
public MyInputStream(File file) throws IOException {
fin = new FileInputStream(file);
}
@Override
public int read() throws IOException {
return fin.read();
}
}public class MyInputStream extends java.io.InputStream {
private FileInputStream fin;
public MyInputStream(File file) throws IOException {
fin = new FileInputStream(file);
}
@Override
public int read() throws IOException {
return fin.read();
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
return fin.read(b, off, len);
}
}From the same buckets as this rule.
All static JS/CSS/font/image files MUST use content-hashed filenames (e.g., app.9c1a7b.js) and be served with "Cache-Control: public, max-age=31536000, immutable". HTML and other non-fingerprinted documents MUST be served with "Cache-Control: no-cache" (or equivalent) to enable conditional revalidation.