Bug #2775

Participant state pattern is not synchron with isActive check.

Added by M. Pohling 11 months ago. Updated 11 months ago.

Status:ResolvedStart date:10/17/2018
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:Java
Target version:rsb-0.18

Description

error java.lang.IllegalStateException: deactivate() cannot be called in state StateInactive

setup spread configured via global config file but no spread started.

test code

public static void main(String[] args) {
    LocalServer server = Factory.getInstance().createLocalServer("/test/scope");
    RemoteServer remote = Factory.getInstance().createRemoteServer("/test/scope");

    try {
        server.addMethod("mymethod", new Callback() {
            @Override
            public Event internalInvoke(Event request) throws UserCodeException {
                System.out.println("process task");
                try {
                    while(!Thread.interrupted()) {
                        Thread.sleep(100);
                    }
                } catch (InterruptedException ex) {
                    Thread.currentThread().interrupt();
                    System.out.println("interrupt task");
                    throw new UserCodeException(ex);
                }
                return request;
            }
        });
    } catch (RSBException e) {
        e.printStackTrace();
    }

    System.out.println("activate");
    try {
        server.activate();
    } catch (RSBException e) {
        e.printStackTrace();
    }
    try {
        remote.activate();
    } catch (RSBException e) {
        e.printStackTrace();
    }

    System.out.println("trigger server task");
    try {
        remote.callAsync("mymethod");
    } catch (RSBException e) {
        e.printStackTrace();
    }
    try {
        Thread.sleep(20000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    System.out.println("deactivate");
    try {
        if (server.isActive()) {
            server.deactivate();
        }
    } catch (RSBException | InterruptedException e) {
        e.printStackTrace();
    }
    try {
        if (remote.isActive()) {
            remote.deactivate();
        }
    } catch (RSBException | InterruptedException e) {
        e.printStackTrace();
    }
}

output
/usr/lib/jvm/default-java/bin/java -Dvisualvm.id=394980602692214 -javaagent:/home/divine/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/182.4892.20/lib/idea_rt.jar=57341:/home/divine/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/182.4892.20/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/default-java/jre/lib/charsets.jar:/usr/lib/jvm/default-java/jre/lib/deploy.jar:/usr/lib/jvm/default-java/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/default-java/jre/lib/ext/dnsns.jar:/usr/lib/jvm/default-java/jre/lib/ext/jaccess.jar:/usr/lib/jvm/default-java/jre/lib/ext/jfxrt.jar:/usr/lib/jvm/default-java/jre/lib/ext/localedata.jar:/usr/lib/jvm/default-java/jre/lib/ext/nashorn.jar:/usr/lib/jvm/default-java/jre/lib/ext/sunec.jar:/usr/lib/jvm/default-java/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/default-java/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/default-java/jre/lib/ext/zipfs.jar:/usr/lib/jvm/default-java/jre/lib/javaws.jar:/usr/lib/jvm/default-java/jre/lib/jce.jar:/usr/lib/jvm/default-java/jre/lib/jfr.jar:/usr/lib/jvm/default-java/jre/lib/jfxswt.jar:/usr/lib/jvm/default-java/jre/lib/jsse.jar:/usr/lib/jvm/default-java/jre/lib/management-agent.jar:/usr/lib/jvm/default-java/jre/lib/plugin.jar:/usr/lib/jvm/default-java/jre/lib/resources.jar:/usr/lib/jvm/default-java/jre/lib/rt.jar:/home/divine/local_data/workspace/openbase/bco/module/jul/extension/rsb/com/target/classes:/home/divine/local_data/workspace/openbase/bco/module/jul/extension/rst/interface/target/classes:/home/divine/local_data/.m2/repository/rsb/rst/0.18-SNAPSHOT/rst-0.18-20180206.145148-16.jar:/home/divine/local_data/.m2/repository/rsb/rst-sandbox/0.18-SNAPSHOT/rst-sandbox-0.18-20180206.145155-16.jar:/home/divine/local_data/.m2/repository/rsb/rst-experimental/0.18-SNAPSHOT/rst-experimental-0.18-20181011.150504-30.jar:/home/divine/local_data/workspace/openbase/bco/module/jul/extension/rst/util/target/classes:/home/divine/local_data/workspace/openbase/bco/module/jul/extension/rsb/interface/target/classes:/home/divine/local_data/workspace/openbase/bco/module/jul/exception/target/classes:/home/divine/local_data/workspace/openbase/bco/module/jul/extension/rsb/scope/target/classes:/home/divine/local_data/workspace/openbase/bco/module/jul/extension/rst/processing/target/classes:/home/divine/local_data/workspace/openbase/bco/module/jul/extension/protobuf/target/classes:/home/divine/local_data/workspace/openbase/bco/module/jul/processing/target/classes:/home/divine/local_data/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.7.5/jackson-core-2.7.5.jar:/home/divine/local_data/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.7.5/jackson-databind-2.7.5.jar:/home/divine/local_data/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar:/home/divine/local_data/.m2/repository/com/googlecode/protobuf-java-format/protobuf-java-format/1.4/protobuf-java-format-1.4.jar:/home/divine/local_data/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/home/divine/local_data/.m2/repository/java3d/vecmath/1.3.1/vecmath-1.3.1.jar:/home/divine/local_data/.m2/repository/com/google/code/gson/gson/2.6.2/gson-2.6.2.jar:/home/divine/local_data/workspace/openbase/bco/module/jul/interface/target/classes:/home/divine/local_data/workspace/openbase/bco/module/jul/annotation/target/classes:/home/divine/local_data/workspace/openbase/bco/module/jul/schedule/target/classes:/home/divine/local_data/workspace/openbase/bco/module/jul/pattern/default/target/classes:/home/divine/local_data/.m2/repository/rsb/rsb/0.18-SNAPSHOT/rsb-0.18-20180913.092653-31.jar:/home/divine/local_data/.m2/repository/com/google/protobuf/protobuf-java/2.6.1/protobuf-java-2.6.1.jar:/home/divine/local_data/.m2/repository/com/github/jnr/jnr-ffi/2.0.9/jnr-ffi-2.0.9.jar:/home/divine/local_data/.m2/repository/com/github/jnr/jffi/1.2.11/jffi-1.2.11.jar:/home/divine/local_data/.m2/repository/com/github/jnr/jffi/1.2.11/jffi-1.2.11-native.jar:/home/divine/local_data/.m2/repository/org/ow2/asm/asm/5.0.3/asm-5.0.3.jar:/home/divine/local_data/.m2/repository/org/ow2/asm/asm-commons/5.0.3/asm-commons-5.0.3.jar:/home/divine/local_data/.m2/repository/org/ow2/asm/asm-analysis/5.0.3/asm-analysis-5.0.3.jar:/home/divine/local_data/.m2/repository/org/ow2/asm/asm-tree/5.0.3/asm-tree-5.0.3.jar:/home/divine/local_data/.m2/repository/org/ow2/asm/asm-util/5.0.3/asm-util-5.0.3.jar:/home/divine/local_data/.m2/repository/com/github/jnr/jnr-x86asm/1.0.2/jnr-x86asm-1.0.2.jar:/home/divine/local_data/.m2/repository/org/openbase/jps/3.4.9/jps-3.4.9.jar:/home/divine/local_data/.m2/repository/org/fusesource/jansi/jansi/1.17.1/jansi-1.17.1.jar:/home/divine/local_data/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/home/divine/local_data/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/home/divine/local_data/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/home/divine/local_data/.m2/repository/commons-io/commons-io/2.5/commons-io-2.5.jar org.openbase.jul.extension.rsb.com.RSBTest
activate
Oct 17, 2018 2:37:03 PM rsb.transport.spread.SpreadWrapperImpl makeConnection
WARNING: reoccuring SpreadException during connect to daemon
spread.SpreadException: Socket(): java.net.ConnectException: Connection refused (Connection refused)
    at spread.SpreadConnection.connect(SpreadConnection.java:876)
    at rsb.transport.spread.SpreadWrapperImpl.makeConnection(SpreadWrapperImpl.java:147)
    at rsb.transport.spread.SpreadWrapperImpl.activate(SpreadWrapperImpl.java:251)
    at rsb.transport.spread.RefCountingSpreadWrapper.activate(RefCountingSpreadWrapper.java:76)
    at rsb.transport.spread.SpreadOutConnector.activate(SpreadOutConnector.java:177)
    at rsb.eventprocessing.RouteConfiguratorUtility.activate(RouteConfiguratorUtility.java:90)
    at rsb.eventprocessing.DefaultOutRouteConfigurator.activate(DefaultOutRouteConfigurator.java:66)
    at rsb.Informer$StateInactive.activate(Informer.java:124)
    at rsb.Informer.activate(Informer.java:262)
    at rsb.patterns.Method$StateInactive.activate(Method.java:107)
    at rsb.patterns.Method.activate(Method.java:201)
    at rsb.patterns.LocalMethod.activate(LocalMethod.java:155)
    at rsb.patterns.Server$StateInactive.activate(Server.java:102)
    at rsb.patterns.Server.activate(Server.java:218)
    at org.openbase.jul.extension.rsb.com.RSBTest.main(RSBTest.java:39)

rsb.InitializeException: rsb.InitializeException: Could not create spread connection host=localhost, port=4803
    at rsb.Informer$StateInactive.activate(Informer.java:126)
    at rsb.Informer.activate(Informer.java:262)
    at rsb.patterns.Method$StateInactive.activate(Method.java:107)
    at rsb.patterns.Method.activate(Method.java:201)
    at rsb.patterns.LocalMethod.activate(LocalMethod.java:155)
    at rsb.patterns.Server$StateInactive.activate(Server.java:102)
    at rsb.patterns.Server.activate(Server.java:218)
    at org.openbase.jul.extension.rsb.com.RSBTest.main(RSBTest.java:39)
Caused by: rsb.InitializeException: Could not create spread connection host=localhost, port=4803
    at rsb.transport.spread.SpreadWrapperImpl.makeConnection(SpreadWrapperImpl.java:160)
    at rsb.transport.spread.SpreadWrapperImpl.activate(SpreadWrapperImpl.java:251)
    at rsb.transport.spread.RefCountingSpreadWrapper.activate(RefCountingSpreadWrapper.java:76)
    at rsb.transport.spread.SpreadOutConnector.activate(SpreadOutConnector.java:177)
    at rsb.eventprocessing.RouteConfiguratorUtility.activate(RouteConfiguratorUtility.java:90)
    at rsb.eventprocessing.DefaultOutRouteConfigurator.activate(DefaultOutRouteConfigurator.java:66)
    at rsb.Informer$StateInactive.activate(Informer.java:124)
    ... 7 more
Caused by: spread.SpreadException: Socket(): java.net.ConnectException: Connection refused (Connection refused)
    at spread.SpreadConnection.connect(SpreadConnection.java:876)
    at rsb.transport.spread.SpreadWrapperImpl.makeConnection(SpreadWrapperImpl.java:147)
    ... 13 more
trigger server task
Oct 17, 2018 2:37:03 PM rsb.transport.spread.SpreadWrapperImpl makeConnection
WARNING: reoccuring SpreadException during connect to daemon
spread.SpreadException: Socket(): java.net.ConnectException: Connection refused (Connection refused)
    at spread.SpreadConnection.connect(SpreadConnection.java:876)
    at rsb.transport.spread.SpreadWrapperImpl.makeConnection(SpreadWrapperImpl.java:147)
    at rsb.transport.spread.SpreadWrapperImpl.activate(SpreadWrapperImpl.java:251)
    at rsb.transport.spread.SpreadReceiver$StateInactive.activate(SpreadReceiver.java:232)
    at rsb.transport.spread.SpreadReceiver.activate(SpreadReceiver.java:344)
    at rsb.transport.spread.SpreadInPushConnector.activate(SpreadInPushConnector.java:80)
    at rsb.eventprocessing.RouteConfiguratorUtility.activate(RouteConfiguratorUtility.java:90)
    at rsb.eventprocessing.DefaultPushInRouteConfigurator.activate(DefaultPushInRouteConfigurator.java:69)
    at rsb.Listener$StateInactive.activate(Listener.java:122)
    at rsb.Listener.activate(Listener.java:190)
    at rsb.introspection.ProtocolHandler.activate(ProtocolHandler.java:389)
    at rsb.introspection.IntrospectionParticipantObserver.created(IntrospectionParticipantObserver.java:89)
    at rsb.Factory$ParticipantObserverManager.notifyParticipantCreated(Factory.java:107)
    at rsb.Participant.activate(Participant.java:88)
    at rsb.patterns.Server.access$501(Server.java:54)
    at rsb.patterns.Server$StateInactive.activate(Server.java:104)
    at rsb.patterns.Server.activate(Server.java:218)
    at org.openbase.jul.extension.rsb.com.RSBTest.main(RSBTest.java:44)

Oct 17, 2018 2:37:03 PM rsb.introspection.IntrospectionParticipantObserver created
SEVERE: Exception during creation of introspection protocol
rsb.InitializeException: Could not create spread connection host=localhost, port=4803
    at rsb.transport.spread.SpreadWrapperImpl.makeConnection(SpreadWrapperImpl.java:160)
    at rsb.transport.spread.SpreadWrapperImpl.activate(SpreadWrapperImpl.java:251)
    at rsb.transport.spread.SpreadReceiver$StateInactive.activate(SpreadReceiver.java:232)
    at rsb.transport.spread.SpreadReceiver.activate(SpreadReceiver.java:344)
    at rsb.transport.spread.SpreadInPushConnector.activate(SpreadInPushConnector.java:80)
    at rsb.eventprocessing.RouteConfiguratorUtility.activate(RouteConfiguratorUtility.java:90)
    at rsb.eventprocessing.DefaultPushInRouteConfigurator.activate(DefaultPushInRouteConfigurator.java:69)
    at rsb.Listener$StateInactive.activate(Listener.java:122)
    at rsb.Listener.activate(Listener.java:190)
    at rsb.introspection.ProtocolHandler.activate(ProtocolHandler.java:389)
    at rsb.introspection.IntrospectionParticipantObserver.created(IntrospectionParticipantObserver.java:89)
    at rsb.Factory$ParticipantObserverManager.notifyParticipantCreated(Factory.java:107)
    at rsb.Participant.activate(Participant.java:88)
    at rsb.patterns.Server.access$501(Server.java:54)
    at rsb.patterns.Server$StateInactive.activate(Server.java:104)
    at rsb.patterns.Server.activate(Server.java:218)
    at org.openbase.jul.extension.rsb.com.RSBTest.main(RSBTest.java:44)
Caused by: spread.SpreadException: Socket(): java.net.ConnectException: Connection refused (Connection refused)
    at spread.SpreadConnection.connect(SpreadConnection.java:876)
    at rsb.transport.spread.SpreadWrapperImpl.makeConnection(SpreadWrapperImpl.java:147)
    ... 16 more

Oct 17, 2018 2:37:04 PM rsb.transport.spread.SpreadWrapperImpl makeConnection
WARNING: reoccuring SpreadException during connect to daemon
spread.SpreadException: Socket(): java.net.ConnectException: Connection refused (Connection refused)
    at spread.SpreadConnection.connect(SpreadConnection.java:876)
    at rsb.transport.spread.SpreadWrapperImpl.makeConnection(SpreadWrapperImpl.java:147)
    at rsb.transport.spread.SpreadWrapperImpl.activate(SpreadWrapperImpl.java:251)
    at rsb.transport.spread.RefCountingSpreadWrapper.activate(RefCountingSpreadWrapper.java:76)
    at rsb.transport.spread.SpreadOutConnector.activate(SpreadOutConnector.java:177)
    at rsb.eventprocessing.RouteConfiguratorUtility.activate(RouteConfiguratorUtility.java:90)
    at rsb.eventprocessing.DefaultOutRouteConfigurator.activate(DefaultOutRouteConfigurator.java:66)
    at rsb.Informer$StateInactive.activate(Informer.java:124)
    at rsb.Informer.activate(Informer.java:262)
    at rsb.patterns.Method$StateInactive.activate(Method.java:107)
    at rsb.patterns.Method.activate(Method.java:201)
    at rsb.patterns.RemoteServer.addMethod(RemoteServer.java:452)
    at rsb.patterns.RemoteServer.callAsyncEvent(RemoteServer.java:394)
    at rsb.patterns.RemoteServer.callAsync(RemoteServer.java:116)
    at rsb.patterns.RemoteServer.callAsync(RemoteServer.java:137)
    at org.openbase.jul.extension.rsb.com.RSBTest.main(RSBTest.java:51)

Oct 17, 2018 2:37:04 PM rsb.patterns.RemoteServer callAsyncEvent
WARNING: Exception during method activation: rsb.InitializeException: Could not create spread connection host=localhost, port=4803 Re-throwing it.
rsb.RSBException: rsb.InitializeException: rsb.InitializeException: Could not create spread connection host=localhost, port=4803
    at rsb.patterns.RemoteServer.callAsyncEvent(RemoteServer.java:398)
    at rsb.patterns.RemoteServer.callAsync(RemoteServer.java:116)
    at rsb.patterns.RemoteServer.callAsync(RemoteServer.java:137)
    at org.openbase.jul.extension.rsb.com.RSBTest.main(RSBTest.java:51)
Caused by: rsb.InitializeException: rsb.InitializeException: Could not create spread connection host=localhost, port=4803
    at rsb.Informer$StateInactive.activate(Informer.java:126)
    at rsb.Informer.activate(Informer.java:262)
    at rsb.patterns.Method$StateInactive.activate(Method.java:107)
    at rsb.patterns.Method.activate(Method.java:201)
    at rsb.patterns.RemoteServer.addMethod(RemoteServer.java:452)
    at rsb.patterns.RemoteServer.callAsyncEvent(RemoteServer.java:394)
    ... 3 more
Caused by: rsb.InitializeException: Could not create spread connection host=localhost, port=4803
    at rsb.transport.spread.SpreadWrapperImpl.makeConnection(SpreadWrapperImpl.java:160)
    at rsb.transport.spread.SpreadWrapperImpl.activate(SpreadWrapperImpl.java:251)
    at rsb.transport.spread.RefCountingSpreadWrapper.activate(RefCountingSpreadWrapper.java:76)
    at rsb.transport.spread.SpreadOutConnector.activate(SpreadOutConnector.java:177)
    at rsb.eventprocessing.RouteConfiguratorUtility.activate(RouteConfiguratorUtility.java:90)
    at rsb.eventprocessing.DefaultOutRouteConfigurator.activate(DefaultOutRouteConfigurator.java:66)
    at rsb.Informer$StateInactive.activate(Informer.java:124)
    ... 8 more
Caused by: spread.SpreadException: Socket(): java.net.ConnectException: Connection refused (Connection refused)
    at spread.SpreadConnection.connect(SpreadConnection.java:876)
    at rsb.transport.spread.SpreadWrapperImpl.makeConnection(SpreadWrapperImpl.java:147)
    ... 14 more
Exception in thread "main" java.lang.IllegalStateException: deactivate() cannot be called in state StateInactive
    at rsb.Activatable$State.deactivate(Activatable.java:107)
    at rsb.patterns.Method.deactivate(Method.java:206)
    at rsb.patterns.Server$StateActive.deactivate(Server.java:77)
    at rsb.patterns.Server.deactivate(Server.java:225)
    at org.openbase.jul.extension.rsb.com.RSBTest.main(RSBTest.java:71)
deactivate

Process finished with exit code 1

Associated revisions

Revision ab34e1bf
Added by J. Wienke 11 months ago

Fix participant state machines after activation failures

fixes #2775

Revision db5408a0
Added by J. Wienke 11 months ago

Fix participant state machines after activation failures

fixes #2775

(cherry picked from commit ab34e1bffefee86bdac7b295d10f40226a7c9b5f)

History

#1 Updated by J. Wienke 11 months ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF