7116890: additional warnings fixes for java.io
Reviewed-by: alanb, smarks
This commit is contained in:
parent
b4263161d9
commit
dc1cd38b85
@ -35,7 +35,7 @@ import java.util.Set;
|
||||
|
||||
class ExpiringCache {
|
||||
private long millisUntilExpiration;
|
||||
private Map map;
|
||||
private Map<String,Entry> map;
|
||||
// Clear out old entries every few queries
|
||||
private int queryCount;
|
||||
private int queryOverflow = 300;
|
||||
@ -61,10 +61,11 @@ class ExpiringCache {
|
||||
this(30000);
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
ExpiringCache(long millisUntilExpiration) {
|
||||
this.millisUntilExpiration = millisUntilExpiration;
|
||||
map = new LinkedHashMap() {
|
||||
protected boolean removeEldestEntry(Map.Entry eldest) {
|
||||
map = new LinkedHashMap<String,Entry>() {
|
||||
protected boolean removeEldestEntry(Map.Entry<String,Entry> eldest) {
|
||||
return size() > MAX_ENTRIES;
|
||||
}
|
||||
};
|
||||
@ -99,7 +100,7 @@ class ExpiringCache {
|
||||
}
|
||||
|
||||
private Entry entryFor(String key) {
|
||||
Entry entry = (Entry) map.get(key);
|
||||
Entry entry = map.get(key);
|
||||
if (entry != null) {
|
||||
long delta = System.currentTimeMillis() - entry.timestamp();
|
||||
if (delta < 0 || delta >= millisUntilExpiration) {
|
||||
@ -111,12 +112,11 @@ class ExpiringCache {
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
Set keySet = map.keySet();
|
||||
Set<String> keySet = map.keySet();
|
||||
// Avoid ConcurrentModificationExceptions
|
||||
String[] keys = new String[keySet.size()];
|
||||
int i = 0;
|
||||
for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
|
||||
String key = (String) iter.next();
|
||||
for (String key: keySet) {
|
||||
keys[i++] = key;
|
||||
}
|
||||
for (int j = 0; j < keys.length; j++) {
|
||||
|
@ -87,6 +87,7 @@ class LineNumberInputStream extends FilterInputStream {
|
||||
* @see java.io.FilterInputStream#in
|
||||
* @see java.io.LineNumberInputStream#getLineNumber()
|
||||
*/
|
||||
@SuppressWarnings("fallthrough")
|
||||
public int read() throws IOException {
|
||||
int c = pushBack;
|
||||
|
||||
|
@ -120,6 +120,7 @@ public class LineNumberReader extends BufferedReader {
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
@SuppressWarnings("fallthrough")
|
||||
public int read() throws IOException {
|
||||
synchronized (lock) {
|
||||
int c = super.read();
|
||||
@ -159,6 +160,7 @@ public class LineNumberReader extends BufferedReader {
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
@SuppressWarnings("fallthrough")
|
||||
public int read(char cbuf[], int off, int len) throws IOException {
|
||||
synchronized (lock) {
|
||||
int n = super.read(cbuf, off, len);
|
||||
|
@ -1075,7 +1075,7 @@ public class ObjectOutputStream
|
||||
} catch (NoSuchMethodException ex) {
|
||||
}
|
||||
try {
|
||||
cl.getDeclaredMethod("putFields", (Class[]) null);
|
||||
cl.getDeclaredMethod("putFields", (Class<?>[]) null);
|
||||
return Boolean.FALSE;
|
||||
} catch (NoSuchMethodException ex) {
|
||||
}
|
||||
|
@ -1049,6 +1049,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
* @param s a string of bytes to be written.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public final void writeBytes(String s) throws IOException {
|
||||
int len = s.length();
|
||||
byte[] b = new byte[len];
|
||||
|
Loading…
Reference in New Issue
Block a user