changeset 153:a9ea3a23598b

8075521: api/jdk/dio/uart/UARTEvent tests hang Summary: Resolved deadlock caused by hidded dependency of close() from 'this' mutex Reviewed-by: alkonsta
author snazarki
date Tue, 07 Apr 2015 15:06:49 +0300
parents 33c00f148c64
children 26032e12a445
files src/share/classes/com/oracle/dio/uart/impl/UARTImpl.java
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/oracle/dio/uart/impl/UARTImpl.java	Mon Apr 06 21:51:04 2015 +0400
+++ b/src/share/classes/com/oracle/dio/uart/impl/UARTImpl.java	Tue Apr 07 15:06:49 2015 +0300
@@ -488,7 +488,7 @@
      * Starts asynchronous writing in successive rounds.
      */
     @Override
-    public synchronized void startWriting(ByteBuffer src1, ByteBuffer src2, OutputRoundListener<UART, ByteBuffer> listener) throws IOException,
+    public void startWriting(ByteBuffer src1, ByteBuffer src2, OutputRoundListener<UART, ByteBuffer> listener) throws IOException,
         UnavailableDeviceException, ClosedDeviceException{
 
         if(src1 == null || src2 == null || listener == null){
@@ -522,7 +522,7 @@
      * Stops (cancels) the currently active writing session.
      */
     @Override
-    public synchronized void stopWriting() throws IOException, UnavailableDeviceException, ClosedDeviceException{
+    public void stopWriting() throws IOException, UnavailableDeviceException, ClosedDeviceException{
         checkOpen();
         synchronized(synchWriteLock) {
             if (isWriting){
@@ -588,6 +588,7 @@
     }
 
 
+    /* stop operation of required type only, e.g. public stopReading() doesn't affect read() */
     private void stopReading(boolean syncVer) throws IOException, UnavailableDeviceException, ClosedDeviceException {
         synchronized(synchReadLock) {
             if (null != inRoundListener && syncVer == (inRoundListener instanceof InternalRoundListener) ) {
@@ -729,15 +730,15 @@
     }
 
     @Override
-    public synchronized void close() throws IOException{
+    public void close() throws IOException{
         if (isOpen()) {
             stopWriting();
             stopReading();
             super.close();
-            // unblock read()
-            synchronized(synchReadLock) {
-                synchReadLock.notifyAll();
-            }
+        }
+        // unblock read()
+        synchronized(synchReadLock) {
+            synchReadLock.notifyAll();
         }
     }