Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315744

Summary: Start properties STOP.PORT and STOP.KEY do not work (the corresponding *system* properties work fine)
Product: [RT] Jetty Reporter: Hussein Shafie <hussein>
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jesse.mcconnell, jetty-inbox
Version: unspecified   
Target Milestone: 7.0.2.RC0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patches jetty-7.1.3.v20100526/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java jesse.mcconnell: iplog+

Description Hussein Shafie CLA 2010-06-04 05:39:16 EDT
Build Identifier: Revision 1917: /jetty/tags/jetty-7.1.3.v20100526

If you add something like:

STOP.PORT=8079
STOP.KEY=secret

in start.ini. Such start options are taken into account. That is, both "java -jar start.jar --help" and "java -jar start.jar" work as expected.

However running "java -jar start.jar --stop" raises an exception:

---
java.lang.NumberFormatException: For input string: "secret"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:447)
        at java.lang.Integer.parseInt(Integer.java:497)
        at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:131)
        at org.eclipse.jetty.start.Main.main(Main.java:77)
---

Note that specifying "-DSTOP.PORT=8079" and "-DSTOP.KEY=secret" in the "java -jar start.jar" command-line works fine. The problem occurs only with the *start* properties and not with the system properties.

What follows fixes this bug:

---
*** Main.java	2010-06-04 10:01:15.000000000 +0200
--- /home/hussein/src/xdr/scripts/JETTY_BUG/Main.java	2010-06-03 19:04:50.000000000 +0200
***************
*** 128,135 ****
  
                  if ("--stop".equals(arg))
                  {
!                     int port = Integer.parseInt(_config.getProperty("STOP.KEY",System.getProperty("STOP.PORT","-1")));
!                     String key = _config.getProperty("STOP.KETY",System.getProperty("STOP.KEY",null));
                      stop(port,key);
                      return;
                  }
--- 128,135 ----
  
                  if ("--stop".equals(arg))
                  {
!                     int port = Integer.parseInt(_config.getProperty("STOP.PORT",System.getProperty("STOP.PORT","-1")));
!                     String key = _config.getProperty("STOP.KEY",System.getProperty("STOP.KEY",null));
                      stop(port,key);
                      return;
                  }
***************
*** 1044,1051 ****
  
      private void startMonitor()
      {
!         int port = Integer.parseInt(System.getProperty("STOP.PORT","-1"));
!         String key = System.getProperty("STOP.KEY",null);
  
          Monitor.monitor(port,key);
      }
--- 1044,1051 ----
  
      private void startMonitor()
      {
!         int port = Integer.parseInt(_config.getProperty("STOP.PORT",System.getProperty("STOP.PORT","-1")));
!         String key = _config.getProperty("STOP.KEY",System.getProperty("STOP.KEY",null));
  
          Monitor.monitor(port,key);
      }
---


Reproducible: Always

Steps to Reproduce:
1. Add:

STOP.PORT=8079
STOP.KEY=secret

to start.ini

2. Run "java -jar start.jar &"

3. Run "java -jar start.jar --stop"
Comment 1 Hussein Shafie CLA 2010-06-04 05:44:44 EDT
Created attachment 171082 [details]
Patches jetty-7.1.3.v20100526/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java

This patch has been generated by running the following command in 
jetty-7.1.3.v20100526/jetty-start/src/main/java/org/eclipse/jetty/start/:

diff -c Main.java ~/src/xdr/scripts/JETTY_BUG/Main.java
Comment 2 Greg Wilkins CLA 2010-06-04 06:05:49 EDT
thanks for the patch.
committed r1918