Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/rmi/server/Activation.java
          +++ new/src/share/classes/sun/rmi/server/Activation.java
↓ open down ↓ 130 lines elided ↑ open up ↑
 131  131   * activation groups fail so that it can remove stale remote references
 132  132   * from its internal tables. <p>
 133  133   *
 134  134   * @author      Ann Wollrath
 135  135   * @since       1.2
 136  136   */
 137  137  public class Activation implements Serializable {
 138  138  
 139  139      /** indicate compatibility with JDK 1.2 version of class */
 140  140      private static final long serialVersionUID = 2921265612698155191L;
 141      -
 142  141      private static final byte MAJOR_VERSION = 1;
 143  142      private static final byte MINOR_VERSION = 0;
 144  143  
 145  144      /** exec policy object */
 146  145      private static Object execPolicy;
 147  146      private static Method execPolicyMethod;
 148  147      private static boolean debugExec;
 149  148  
 150  149      /** maps activation id to its respective group id */
 151  150      private Map<ActivationID,ActivationGroupID> idTable =
↓ open down ↓ 139 lines elided ↑ open up ↑
 291  290              groupTable = new ConcurrentHashMap<>(groupTable);
 292  291          }
 293  292          if (! (idTable instanceof ConcurrentHashMap)) {
 294  293              idTable = new ConcurrentHashMap<>(idTable);
 295  294          }
 296  295      }
 297  296  
 298  297      private static class SystemRegistryImpl extends RegistryImpl {
 299  298  
 300  299          private static final String NAME = ActivationSystem.class.getName();
      300 +        private static final long serialVersionUID = 4877330021609408794L;
 301  301          private final ActivationSystem systemStub;
 302  302  
 303  303          SystemRegistryImpl(int port,
 304  304                             RMIClientSocketFactory csf,
 305  305                             RMIServerSocketFactory ssf,
 306  306                             ActivationSystem systemStub)
 307  307              throws RemoteException
 308  308          {
 309  309              super(port, csf, ssf);
 310  310              this.systemStub = systemStub;
↓ open down ↓ 486 lines elided ↑ open up ↑
 797  797          private static final long serialVersionUID = 7222464070032993304L;
 798  798          private static final int MAX_TRIES = 2;
 799  799          private static final int NORMAL = 0;
 800  800          private static final int CREATING = 1;
 801  801          private static final int TERMINATE = 2;
 802  802          private static final int TERMINATING = 3;
 803  803  
 804  804          ActivationGroupDesc desc = null;
 805  805          ActivationGroupID groupID = null;
 806  806          long incarnation = 0;
 807      -        Map<ActivationID,ObjectEntry> objects =
 808      -            new HashMap<ActivationID,ObjectEntry>();
 809      -        Set<ActivationID> restartSet = new HashSet<ActivationID>();
      807 +        Map<ActivationID,ObjectEntry> objects = new HashMap<>();
      808 +        Set<ActivationID> restartSet = new HashSet<>();
 810  809  
 811  810          transient ActivationInstantiator group = null;
 812  811          transient int status = NORMAL;
 813  812          transient long waitTime = 0;
 814  813          transient String groupName = null;
 815  814          transient Process child = null;
 816  815          transient boolean removed = false;
 817  816          transient Watchdog watchdog = null;
 818  817  
 819  818          GroupEntry(ActivationGroupID groupID, ActivationGroupDesc desc) {
↓ open down ↓ 230 lines elided ↑ open up ↑
1050 1049  
1051 1050          private void terminate() {
1052 1051              if (child != null && status != TERMINATING) {
1053 1052                  child.destroy();
1054 1053                  status = TERMINATING;
1055 1054                  waitTime = System.currentTimeMillis() + groupTimeout;
1056 1055                  notifyAll();
1057 1056              }
1058 1057          }
1059 1058  
     1059 +       /*
     1060 +        * Fallthrough from TERMINATE to TERMINATING
     1061 +        * is intentional
     1062 +        */
     1063 +        @SuppressWarnings("fallthrough")
1060 1064          private void await() {
1061 1065              while (true) {
1062 1066                  switch (status) {
1063 1067                  case NORMAL:
1064 1068                      return;
1065 1069                  case TERMINATE:
1066 1070                      terminate();
1067 1071                  case TERMINATING:
1068 1072                      try {
1069 1073                          child.exitValue();
↓ open down ↓ 151 lines elided ↑ open up ↑
1221 1225                      status = CREATING;
1222 1226                      ++incarnation;
1223 1227                      watchdog = new Watchdog();
1224 1228                      watchdog.start();
1225 1229                      addLogRecord(new LogGroupIncarnation(id, incarnation));
1226 1230  
1227 1231                      // handle child I/O streams before writing to child
1228 1232                      PipeWriter.plugTogetherPair
1229 1233                          (child.getInputStream(), System.out,
1230 1234                           child.getErrorStream(), System.err);
     1235 +                    try (MarshalOutputStream out = 
     1236 +                            new MarshalOutputStream(child.getOutputStream())) {
     1237 +                        out.writeObject(id);
     1238 +                        out.writeObject(desc);
     1239 +                        out.writeLong(incarnation);
     1240 +                        out.flush();
     1241 +                    }
1231 1242  
1232      -                    MarshalOutputStream out =
1233      -                        new MarshalOutputStream(child.getOutputStream());
1234      -                    out.writeObject(id);
1235      -                    out.writeObject(desc);
1236      -                    out.writeLong(incarnation);
1237      -                    out.flush();
1238      -                    out.close();
1239 1243  
1240      -
1241 1244                  } catch (IOException e) {
1242 1245                      terminate();
1243 1246                      throw new ActivationException(
1244 1247                          "unable to create activation group", e);
1245 1248                  }
1246 1249  
1247 1250                  try {
1248 1251                      long now = System.currentTimeMillis();
1249 1252                      long stop = now + execTimeout;
1250 1253                      do {
↓ open down ↓ 94 lines elided ↑ open up ↑
1345 1348                  shouldRestart = false;
1346 1349              }
1347 1350          }
1348 1351      }
1349 1352  
1350 1353      private String[] activationArgs(ActivationGroupDesc desc) {
1351 1354          ActivationGroupDesc.CommandEnvironment cmdenv;
1352 1355          cmdenv = desc.getCommandEnvironment();
1353 1356  
1354 1357          // argv is the literal command to exec
1355      -        List<String> argv = new ArrayList<String>();
     1358 +        List<String> argv = new ArrayList<>();
1356 1359  
1357 1360          // Command name/path
1358 1361          argv.add((cmdenv != null && cmdenv.getCommandPath() != null)
1359 1362                      ? cmdenv.getCommandPath()
1360 1363                      : command[0]);
1361 1364  
1362 1365          // Group-specific command options
1363 1366          if (cmdenv != null && cmdenv.getCommandOptions() != null) {
1364 1367              argv.addAll(Arrays.asList(cmdenv.getCommandOptions()));
1365 1368          }
↓ open down ↓ 584 lines elided ↑ open up ↑
1950 1953                  port = serverSocket.getLocalPort();
1951 1954                  ssf = new ActivationServerSocketFactory(serverSocket);
1952 1955  
1953 1956                  System.err.println(new Date());
1954 1957                  System.err.println(getTextResource(
1955 1958                                         "rmid.inherited.channel.info") +
1956 1959                                         ": " + inheritedChannel);
1957 1960              }
1958 1961  
1959 1962              String log = null;
1960      -            List<String> childArgs = new ArrayList<String>();
     1963 +            List<String> childArgs = new ArrayList<>();
1961 1964  
1962 1965              /*
1963 1966               * Parse arguments
1964 1967               */
1965 1968              for (int i = 0; i < args.length; i++) {
1966 1969                  if (args[i].equals("-port")) {
1967 1970                      if (ssf != null) {
1968 1971                          bomb(getTextResource("rmid.syntax.port.badarg"));
1969 1972                      }
1970 1973                      if ((i + 1) < args.length) {
↓ open down ↓ 53 lines elided ↑ open up ↑
2024 2027               * Initialize method for activation exec policy.
2025 2028               */
2026 2029              if (!execPolicyClassName.equals("none")) {
2027 2030                  if (execPolicyClassName.equals("") ||
2028 2031                      execPolicyClassName.equals("default"))
2029 2032                  {
2030 2033                      execPolicyClassName = DefaultExecPolicy.class.getName();
2031 2034                  }
2032 2035  
2033 2036                  try {
2034      -                    Class<?> execPolicyClass =
2035      -                        RMIClassLoader.loadClass(execPolicyClassName);
     2037 +                    Class<?> execPolicyClass = getRMIClass(execPolicyClassName);
     2038 +                        
2036 2039                      execPolicy = execPolicyClass.newInstance();
2037 2040                      execPolicyMethod =
2038 2041                          execPolicyClass.getMethod("checkExecCommand",
2039 2042                                                    ActivationGroupDesc.class,
2040 2043                                                    String[].class);
2041 2044                  } catch (Exception e) {
2042 2045                      if (debugExec) {
2043 2046                          System.err.println(
2044 2047                              getTextResource("rmid.exec.policy.exception"));
2045 2048                          e.printStackTrace();
↓ open down ↓ 70 lines elided ↑ open up ↑
2116 2119          } catch (MissingResourceException mre) {
2117 2120          }
2118 2121  
2119 2122          if (val == null) {
2120 2123              return ("[missing resource: " + key + "]");
2121 2124          } else {
2122 2125              return val;
2123 2126          }
2124 2127      }
2125 2128  
     2129 +    @SuppressWarnings("deprecation")
     2130 +    private static Class<?> getRMIClass(String execPolicyClassName) throws Exception  {
     2131 +        return RMIClassLoader.loadClass(execPolicyClassName);
     2132 +    }
2126 2133      /*
2127 2134       * Dijkstra semaphore operations to limit the number of subprocesses
2128 2135       * rmid attempts to make at once.
2129 2136       */
2130 2137      /**
2131 2138       * Acquire the group semaphore and return a group name.  Each
2132 2139       * Pstartgroup must be followed by a Vstartgroup.  The calling thread
2133 2140       * will wait until there are fewer than <code>N</code> other threads
2134 2141       * holding the group semaphore.  The calling thread will then acquire
2135 2142       * the semaphore and return.
↓ open down ↓ 367 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX