Commit 9d9bd40f by Tom Tromey Committed by Tom Tromey

Charset.java (encode, decode): Synchronize on 'this', not the class.

	* java/nio/charset/Charset.java (encode, decode): Synchronize on
	'this', not the class.

From-SVN: r99810
parent e5b58ee3
2005-05-16 Tom Tromey <tromey@redhat.com> 2005-05-16 Tom Tromey <tromey@redhat.com>
* java/nio/charset/Charset.java (encode, decode): Synchronize on
'this', not the class.
2005-05-16 Tom Tromey <tromey@redhat.com>
* gnu/java/net/protocol/http/Headers.java (parse): Include final * gnu/java/net/protocol/http/Headers.java (parse): Include final
character of line. character of line.
......
...@@ -289,15 +289,13 @@ public abstract class Charset implements Comparable ...@@ -289,15 +289,13 @@ public abstract class Charset implements Comparable
return true; return true;
} }
public final ByteBuffer encode (CharBuffer cb)
{
try
{
// NB: This implementation serializes different threads calling // NB: This implementation serializes different threads calling
// Charset.encode(), a potential performance problem. It might // Charset.encode(), a potential performance problem. It might
// be better to remove the cache, or use ThreadLocal to cache on // be better to remove the cache, or use ThreadLocal to cache on
// a per-thread basis. // a per-thread basis.
synchronized (Charset.class) public final synchronized ByteBuffer encode (CharBuffer cb)
{
try
{ {
if (cachedEncoder == null) if (cachedEncoder == null)
{ {
...@@ -308,7 +306,6 @@ public abstract class Charset implements Comparable ...@@ -308,7 +306,6 @@ public abstract class Charset implements Comparable
cachedEncoder.reset(); cachedEncoder.reset();
return cachedEncoder.encode (cb); return cachedEncoder.encode (cb);
} }
}
catch (CharacterCodingException e) catch (CharacterCodingException e)
{ {
throw new AssertionError (e); throw new AssertionError (e);
...@@ -320,15 +317,13 @@ public abstract class Charset implements Comparable ...@@ -320,15 +317,13 @@ public abstract class Charset implements Comparable
return encode (CharBuffer.wrap (str)); return encode (CharBuffer.wrap (str));
} }
public final CharBuffer decode (ByteBuffer bb)
{
try
{
// NB: This implementation serializes different threads calling // NB: This implementation serializes different threads calling
// Charset.decode(), a potential performance problem. It might // Charset.decode(), a potential performance problem. It might
// be better to remove the cache, or use ThreadLocal to cache on // be better to remove the cache, or use ThreadLocal to cache on
// a per-thread basis. // a per-thread basis.
synchronized (Charset.class) public final synchronized CharBuffer decode (ByteBuffer bb)
{
try
{ {
if (cachedDecoder == null) if (cachedDecoder == null)
{ {
...@@ -340,7 +335,6 @@ public abstract class Charset implements Comparable ...@@ -340,7 +335,6 @@ public abstract class Charset implements Comparable
return cachedDecoder.decode (bb); return cachedDecoder.decode (bb);
} }
}
catch (CharacterCodingException e) catch (CharacterCodingException e)
{ {
throw new AssertionError (e); throw new AssertionError (e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment