-
Bug
-
Resolution: Fixed
-
P5
-
5.0u1, 6
-
b03
-
generic, x86
-
generic, linux
-
Not verified
In method java.netURI.decode(String) there is an assignment to a local object called "ba", but it is never used in the method.
private static String decode(String s) {
if (s == null)
return s;
int n = s.length();
if (n == 0)
return s;
if (s.indexOf('%') < 0)
return s;
byte[] ba = new byte[n]; // <------------------- here
StringBuffer sb = new StringBuffer(n);
ByteBuffer bb = ByteBuffer.allocate(n);
CharBuffer cb = CharBuffer.allocate(n);
CharsetDecoder dec = ThreadLocalCoders.decoderFor("UTF-8")
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE);
// This is not horribly efficient, but it will do for now
char c = s.charAt(0);
boolean betweenBrackets = false;
for (int i = 0; i < n;) {
assert c == s.charAt(i); // Loop invariant
if (c == '[') {
betweenBrackets = true;
} else if (betweenBrackets && c == ']') {
betweenBrackets = false;
}
if (c != '%' || betweenBrackets) {
sb.append(c);
if (++i >= n)
break;
c = s.charAt(i);
continue;
}
bb.clear();
int ui = i;
for (;;) {
assert (n - i >= 2);
bb.put(decode(s.charAt(++i), s.charAt(++i)));
if (++i >= n)
break;
c = s.charAt(i);
if (c != '%')
break;
}
bb.flip();
cb.clear();
dec.reset();
CoderResult cr = dec.decode(bb, cb, true);
assert cr.isUnderflow();
cr = dec.flush(cb);
assert cr.isUnderflow();
sb.append(cb.flip().toString());
}
return sb.toString();
}
###@###.### 2005-03-10 16:11:14 GMT
private static String decode(String s) {
if (s == null)
return s;
int n = s.length();
if (n == 0)
return s;
if (s.indexOf('%') < 0)
return s;
byte[] ba = new byte[n]; // <------------------- here
StringBuffer sb = new StringBuffer(n);
ByteBuffer bb = ByteBuffer.allocate(n);
CharBuffer cb = CharBuffer.allocate(n);
CharsetDecoder dec = ThreadLocalCoders.decoderFor("UTF-8")
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE);
// This is not horribly efficient, but it will do for now
char c = s.charAt(0);
boolean betweenBrackets = false;
for (int i = 0; i < n;) {
assert c == s.charAt(i); // Loop invariant
if (c == '[') {
betweenBrackets = true;
} else if (betweenBrackets && c == ']') {
betweenBrackets = false;
}
if (c != '%' || betweenBrackets) {
sb.append(c);
if (++i >= n)
break;
c = s.charAt(i);
continue;
}
bb.clear();
int ui = i;
for (;;) {
assert (n - i >= 2);
bb.put(decode(s.charAt(++i), s.charAt(++i)));
if (++i >= n)
break;
c = s.charAt(i);
if (c != '%')
break;
}
bb.flip();
cb.clear();
dec.reset();
CoderResult cr = dec.decode(bb, cb, true);
assert cr.isUnderflow();
cr = dec.flush(cb);
assert cr.isUnderflow();
sb.append(cb.flip().toString());
}
return sb.toString();
}
###@###.### 2005-03-10 16:11:14 GMT
- duplicates
-
JDK-6473471 unused local variable ba in URI decode(String s) method
- Closed