< prev index next >

src/java.base/share/classes/sun/nio/ch/IOUtil.java

Print this page
*** 473,19 ***
          }
      }
  
      private static final JavaNioAccess NIO_ACCESS = SharedSecrets.getJavaNioAccess();
  
!     static Scope.Handle acquireScope(ByteBuffer bb, boolean async) {
          return NIO_ACCESS.acquireScope(bb, async);
      }
  
!     private static void releaseScope(Scope.Handle handle) {
          if (handle == null)
              return;
          try {
!             handle.scope().release(handle);
          } catch (Exception e) {
              throw new IllegalStateException(e);
          }
      }
  
--- 473,19 ---
          }
      }
  
      private static final JavaNioAccess NIO_ACCESS = SharedSecrets.getJavaNioAccess();
  
!     static Runnable acquireScope(ByteBuffer bb, boolean async) {
          return NIO_ACCESS.acquireScope(bb, async);
      }
  
!     private static void releaseScope(Runnable handle) {
          if (handle == null)
              return;
          try {
!             handle.run();
          } catch (Exception e) {
              throw new IllegalStateException(e);
          }
      }
  

*** 533,15 ***
          static LinkedRunnable of(Runnable first, Runnable second) {
              return new LinkedRunnable(first, second);
          }
      }
  
!     static record Releaser(Scope.Handle handle) implements Runnable {
          Releaser { Objects.requireNonNull(handle) ; }
          @Override public void run() { releaseScope(handle); }
!         static Runnable of(Scope.Handle handle) { return new Releaser(handle); }
!         static Runnable ofNullable(Scope.Handle handle) {
              if (handle == null)
                  return () -> { };
              return new Releaser(handle);
          }
      }
--- 533,15 ---
          static LinkedRunnable of(Runnable first, Runnable second) {
              return new LinkedRunnable(first, second);
          }
      }
  
!     static record Releaser(Runnable handle) implements Runnable {
          Releaser { Objects.requireNonNull(handle) ; }
          @Override public void run() { releaseScope(handle); }
!         static Runnable of(Runnable handle) { return new Releaser(handle); }
!         static Runnable ofNullable(Runnable handle) {
              if (handle == null)
                  return () -> { };
              return new Releaser(handle);
          }
      }
< prev index next >