GithubHelp home page GithubHelp logo

research-virtualfortknox / msb-client-websocket-java Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 3.0 572 KB

The java client library to connect to the websocket interface of the MSB (Manufacturing Service Bus)

License: Apache License 2.0

Java 100.00%
java msb websocket-interface msb-client msb-client-websocket

msb-client-websocket-java's People

Contributors

daniel-schel avatar ipamaas avatar lgtm-migrator avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

msb-client-websocket-java's Issues

Map<Integer, CustomObject> is deserialized as empty Map

Receiving an Object containing a Map (i.e. Map<Integer, CustomObject> via MSB function handler is not possible, because the data will be deserialized with an empty map.

When we receive the same JSON as a String (not as typed object) and perform the marshalling JSON to java object manually in our code, we can get the desired Map with all items mentioned in the JSON String.

Tested with:
Python websocket client -> MSB -> Java websocket client
Java websocket client -> MSB -> Java websocket client

To Reproduce
Steps to reproduce the behavior:

  1. Create a function handler to receive an Object containing a Map<Integer, YourObject> as the desired type
  2. Create a function handler to receive an Object containing a Map<Integer, YourObject> as String (raw JSON string)
  3. Send an instanciated Map<Integer, YourObject> with at least one item (key-value pair) to the typed function of the java websocket client
  4. Log received Map instance and check if Map contains any data
  5. Send the same instanciated Map<Integer, YourObject> with at least one item (key-value pair) to the String-receiving function of the java websocket client and perform the marshalling in your code
  6. log manually marshalled Map instance and check if Map contains any data
  7. Compare both results. It must not be empty for both cases.

Expected behavior
When receiving a Map (or HashMap) the data should be deserialized as a filled Map with all the transmitted content (all items mentioned in the received JSON). This must be the case for Objects containing nested Maps (or HashMaps), too.

Environment:

  • MSB client version 1.0.1
  • MSB version 1.5.7-RELEASE

Additional context

########################################################

@Log // lombok
@Component
@FunctionHandler(path = "/functionhandler")
public class MSBFunctionHandler {

    @FunctionCall(path = "/update", description = "", name = "update")
    public void update(@FunctionParam(name = "sortedItems") SortedItems sortedItems) throws Exception {
        log.info("List was empty: " + sortedItems.getTheListWithItems().isEmpty());
    }

    @FunctionCall(path = "/updateWithJSON", description = "", name = "updateWithJSON")
    public void updateWithJSON(@FunctionParam(name = "sortedItems") String jsonInput) throws Exception {
        log.fine("############# RAW JSON #############\n\n" + jsonInput + "\n\n");
        try {
            ObjectMapper mapper = new ObjectMapper();

            TypeReference<SortedItems> typeRef
                    = new TypeReference<SortedItems>() {};
            SortedItems items = mapper.readValue(jsonInput, typeRef);

            update(items);
        } catch (Exception e) {
            log.severe("Cannot handle raw JSON! " + e.getMessage() + "\n\n" + jsonInput + "\n\n");
            throw e;
        }

    }

}

########################################################

@Data // lombok
public class SortedItems {

    Map<Integer, YourObject> theListWithItems;

}

########################################################

@Data // lombok
public class YourObject {

    private String foo;
    private double bar;

}

Unhandled null return value at function invocation

Describe the bug
If a function with defined response event returns null this will not be catched and an event without data will be generated.

Expected behavior
This can lead to errors in consuming services, so if the return value is null, no event should be generated and an error should be logged instead.

Environment (please complete the following information):
MSB client version v1.0.5

No log output on plain java applications

Describe the bug
The MSB Client does not show any console log output if the application is a plain java application. If you add @SpringBootApplication and spring dependencies to pom.xml the output works.

Console is showing
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

To Reproduce
Dependencies of pom.xml of plain java app:

<dependencies>
         <dependency>
            <groupId>com.github.research-virtualfortknox</groupId>
            <artifactId>msb-client-websocket</artifactId>
            <version>1.0.2-RELEASE</version>
        </dependency>
</dependencies>

Dependencies of spring app:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.github.research-virtualfortknox</groupId>
            <artifactId>msb-client-websocket</artifactId>
            <version>1.0.2-RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.29</version>
        </dependency>
</dependencies>

Expected behavior
MSB Client should print logs to console if used in plain java applications.

Environment (please complete the following information):

  • MSB client version v1.0.2-RELEASE
  • MSB version 1.5.8-RELEASE

Client hangs after reconnect

Describe the bug
If the connection is closed on the server side during the first registration, the connection is re-established, but the registration is not executed again. The client then hangs on this state.

To Reproduce
Steps to reproduce the behavior:

  1. client establishes the connection
  2. registration is initiated
  3. connection is closed during registration by the server
  4. a new connection is established

Expected behavior
The client should run the regsitrieung again.

Environment (please complete the following information):

  • MSB client version v1.0.6
  • MSB version 1.6.2-SNAPSHOT

Additional context
error.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.