Uploaded image for project: 'WildFly Core'
  1. WildFly Core
  2. WFCORE-1417

org.jboss.as.cli.scriptsupport.CLI connect methods do not properly reset the ctx upon failure making in turn checkNotConnected() to report incorrectly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • None
    • 2.1.0.CR1
    • CLI
    • None
    • Hide

      1. Attempt to connect via CLI.connect(...)
      2. Connection fails because EAP is not running yet. CLI throws "java.lang.IllegalStateException: Unable to connect to controller"
      3. Attempt to connect again.
      4. CLI throws exception "java.lang.IllegalStateException: Already connected to server."
      This message is incorrect. No connection has been established and should you 'accept' this fact, then any subsequent action (for example sending a command) will fail

      Show
      1. Attempt to connect via CLI.connect(...) 2. Connection fails because EAP is not running yet. CLI throws "java.lang.IllegalStateException: Unable to connect to controller" 3. Attempt to connect again. 4. CLI throws exception "java.lang.IllegalStateException: Already connected to server." This message is incorrect. No connection has been established and should you 'accept' this fact, then any subsequent action (for example sending a command) will fail
    • Low

      cli/src/main/java/org/jboss/as/cli/scriptsupport/CLI.java

      public void connect() {
      checkAlreadyConnected();
      try

      { ctx = CommandContextFactory.getInstance().newCommandContext(); ctx.connectController(); }

      catch (CliInitializationException e)

      { throw new IllegalStateException("Unable to initialize command context.", e); }

      catch (CommandLineException e)

      { throw new IllegalStateException("Unable to connect to controller.", e); }

      }

      also applicable to the other connects of course.

      If the connection fails in the connect method, a subsequent connect will hit:

      private void checkAlreadyConnected()

      { if (ctx != null) throw new IllegalStateException("Already connected to server."); }

      and will fail for the wrong reason... as while ctx !=null is true, but the connection had failed.

      ergo, upon failure in connect, the ctx should be reset to avoid this

            jdenise@redhat.com Jean Francois Denise
            tfonteyn Tom Fonteyne (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: