提交 388f5838 编写于 作者: S smarks

7116890: additional warnings fixes for java.io

Reviewed-by: alanb, smarks
Contributed-by: NSebastian Sickelmann <sebastian.sickelmann@gmx.de>
上级 a8848efe
......@@ -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];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册