You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/11/27 01:47:32 UTC
[groovy] branch GROOVY_2_4_X updated (ad7276c -> ee8deb2)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a change to branch GROOVY_2_4_X
in repository https://gitbox.apache.org/repos/asf/groovy.git.
from ad7276c GROOVY-9818: JSP-API license seems to be missing cont'd
new 00e4d90 GROOVY-9826: Better propagation of InterruptedException (port to 2_4_X)
new ee8deb2 GROOVY-9826: Better propagation of InterruptedException (additional case)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../groovy/runtime/DefaultGroovyStaticMethods.java | 5 +-
.../groovy/runtime/ProcessGroovyMethods.java | 26 ++--
.../org/codehaus/groovy/util/ReferenceManager.java | 1 +
.../groovy/jmx/builder/JmxConnectorHelper.java | 132 ++++++++++-----------
4 files changed, 88 insertions(+), 76 deletions(-)
[groovy] 01/02: GROOVY-9826: Better propagation of
InterruptedException (port to 2_4_X)
Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_2_4_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 00e4d903330b707dc3ce44b2aa2a33095d1f4720
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu Nov 26 14:26:49 2020 +1000
GROOVY-9826: Better propagation of InterruptedException (port to 2_4_X)
---
.../groovy/runtime/ProcessGroovyMethods.java | 26 ++--
.../org/codehaus/groovy/util/ReferenceManager.java | 1 +
.../groovy/jmx/builder/JmxConnectorHelper.java | 132 ++++++++++-----------
3 files changed, 85 insertions(+), 74 deletions(-)
diff --git a/src/main/org/codehaus/groovy/runtime/ProcessGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
index 02204c5..7327a52 100644
--- a/src/main/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
@@ -241,10 +241,15 @@ public class ProcessGroovyMethods extends DefaultGroovyMethodsSupport {
public static void waitForProcessOutput(Process self, Appendable output, Appendable error) {
Thread tout = consumeProcessOutputStream(self, output);
Thread terr = consumeProcessErrorStream(self, error);
- try { tout.join(); } catch (InterruptedException ignore) {}
- try { terr.join(); } catch (InterruptedException ignore) {}
- try { self.waitFor(); } catch (InterruptedException ignore) {}
- closeStreams(self);
+ boolean interrupted = false;
+ try {
+ try { tout.join(); } catch (InterruptedException ignore) { interrupted = true; }
+ try { terr.join(); } catch (InterruptedException ignore) { interrupted = true; }
+ try { self.waitFor(); } catch (InterruptedException ignore) { interrupted = true; }
+ closeStreams(self);
+ } finally {
+ if (interrupted) Thread.currentThread().interrupt();
+ }
}
/**
@@ -263,10 +268,15 @@ public class ProcessGroovyMethods extends DefaultGroovyMethodsSupport {
public static void waitForProcessOutput(Process self, OutputStream output, OutputStream error) {
Thread tout = consumeProcessOutputStream(self, output);
Thread terr = consumeProcessErrorStream(self, error);
- try { tout.join(); } catch (InterruptedException ignore) {}
- try { terr.join(); } catch (InterruptedException ignore) {}
- try { self.waitFor(); } catch (InterruptedException ignore) {}
- closeStreams(self);
+ boolean interrupted = false;
+ try {
+ try { tout.join(); } catch (InterruptedException ignore) { interrupted = true; }
+ try { terr.join(); } catch (InterruptedException ignore) { interrupted = true; }
+ try { self.waitFor(); } catch (InterruptedException ignore) { interrupted = true; }
+ closeStreams(self);
+ } finally {
+ if (interrupted) Thread.currentThread().interrupt();
+ }
}
/**
diff --git a/src/main/org/codehaus/groovy/util/ReferenceManager.java b/src/main/org/codehaus/groovy/util/ReferenceManager.java
index 6ab6d56..00ef8b3 100644
--- a/src/main/org/codehaus/groovy/util/ReferenceManager.java
+++ b/src/main/org/codehaus/groovy/util/ReferenceManager.java
@@ -36,6 +36,7 @@ public class ReferenceManager {
try {
r = queue.remove(1000);
} catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
break;
}
if (r==null) continue;
diff --git a/subprojects/groovy-jmx/src/test/java/groovy/jmx/builder/JmxConnectorHelper.java b/subprojects/groovy-jmx/src/test/java/groovy/jmx/builder/JmxConnectorHelper.java
index e3fe10c..4e6f904 100644
--- a/subprojects/groovy-jmx/src/test/java/groovy/jmx/builder/JmxConnectorHelper.java
+++ b/subprojects/groovy-jmx/src/test/java/groovy/jmx/builder/JmxConnectorHelper.java
@@ -1,66 +1,66 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package groovy.jmx.builder;
-
-import java.rmi.NoSuchObjectException;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Helper class to help with RMI
- */
-public class JmxConnectorHelper {
- public static Map createRmiRegistry(int initPort) {
- Map<String, Object> result = new HashMap<String, Object>(2);
- int counter = 0;
- int port = initPort;
- Registry reg = null;
- while (reg == null && counter <= 4) {
- try {
- reg = LocateRegistry.createRegistry(port);
- result.put("registry", reg);
- result.put("port", port);
- break;
- } catch (RemoteException ex) {
- counter++;
- port = port + 1;
- System.out.println("JmxBuilder - *** FAILED *** to create RMI Registry - Will Retry on port [" + port + "].");
- try {
- Thread.currentThread().sleep(500);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- }
- return result;
- }
-
- public static void destroyRmiRegistry(Registry reg) {
- try {
- if (reg != null) {
- java.rmi.server.UnicastRemoteObject.unexportObject(reg, true);
- }
- } catch (NoSuchObjectException e) {
- throw new RuntimeException(e);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package groovy.jmx.builder;
+
+import java.rmi.NoSuchObjectException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Helper class to help with RMI
+ */
+public class JmxConnectorHelper {
+ public static Map createRmiRegistry(int initPort) {
+ Map<String, Object> result = new HashMap<String, Object>(2);
+ int counter = 0;
+ int port = initPort;
+ Registry reg = null;
+ while (reg == null && counter <= 4) {
+ try {
+ reg = LocateRegistry.createRegistry(port);
+ result.put("registry", reg);
+ result.put("port", port);
+ break;
+ } catch (RemoteException ex) {
+ counter++;
+ port = port + 1;
+ System.out.println("JmxBuilder - *** FAILED *** to create RMI Registry - Will Retry on port [" + port + "].");
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ return result;
+ }
+
+ public static void destroyRmiRegistry(Registry reg) {
+ try {
+ if (reg != null) {
+ java.rmi.server.UnicastRemoteObject.unexportObject(reg, true);
+ }
+ } catch (NoSuchObjectException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
[groovy] 02/02: GROOVY-9826: Better propagation of
InterruptedException (additional case)
Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_2_4_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit ee8deb2870177542732f40ace75c4e6ec1adc0b0
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri Nov 27 11:47:12 2020 +1000
GROOVY-9826: Better propagation of InterruptedException (additional case)
---
src/main/org/codehaus/groovy/runtime/DefaultGroovyStaticMethods.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyStaticMethods.java b/src/main/org/codehaus/groovy/runtime/DefaultGroovyStaticMethods.java
index 032fd3d..eaab539 100644
--- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyStaticMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyStaticMethods.java
@@ -276,7 +276,7 @@ public class DefaultGroovyStaticMethods {
final int MAXTRIES = 3;
int accessDeniedCounter = 0;
File tempFile = null;
- for (int i = 0; i < MAXTRIES; i++) {
+ for (int i = 0; i < MAXTRIES && interrupted = null; i++) {
try {
tempFile = File.createTempFile(prefix, suffix);
tempFile.delete();
@@ -287,7 +287,8 @@ public class DefaultGroovyStaticMethods {
accessDeniedCounter++;
try {
Thread.sleep(100);
- } catch (InterruptedException ignore) {
+ } catch (InterruptedException ie) {
+ throw new RuntimeException(ie);
}
}
if (i == MAXTRIES - 1) {