mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
10.37.2012 5dc2a544d39688419f6450afe8582b793b7d4a08
Preparation work for OPENDJ-420: Rare SSLExceptions while handling LDAPS connections and big LDAP searches

Remove small risk of race conditions when redirecting.
1 files modified
26 ■■■■■ changed files
opends/src/server/org/opends/server/extensions/RedirectingByteChannel.java 26 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/RedirectingByteChannel.java
@@ -59,7 +59,6 @@
  private final ByteChannel child;
  private volatile ByteChannel redirect = null;
@@ -76,9 +75,10 @@
   */
  public void close() throws IOException
  {
    if (redirect != null)
    final ByteChannel tmp = redirect;
    if (tmp != null)
    {
      redirect.close();
      tmp.close();
    }
    else
    {
@@ -103,11 +103,15 @@
   */
  public boolean isOpen()
  {
    if (redirect != null)
    final ByteChannel tmp = redirect;
    if (tmp != null)
    {
      return redirect.isOpen();
      return tmp.isOpen();
    }
    return child.isOpen();
    else
    {
      return child.isOpen();
    }
  }
@@ -117,9 +121,10 @@
   */
  public int read(final ByteBuffer buffer) throws IOException
  {
    if (redirect != null)
    final ByteChannel tmp = redirect;
    if (tmp != null)
    {
      return redirect.read(buffer);
      return tmp.read(buffer);
    }
    else
    {
@@ -148,9 +153,10 @@
   */
  public int write(final ByteBuffer buffer) throws IOException
  {
    if (redirect != null)
    final ByteChannel tmp = redirect;
    if (tmp != null)
    {
      return redirect.write(buffer);
      return tmp.write(buffer);
    }
    else
    {