MopeSWTP-SS21 / MopeSWTP

MIT License
1 stars 0 forks source link

getVersion throws exception #69

Closed CSchoel closed 3 years ago

CSchoel commented 3 years ago

Steps to reproduce

Expected behavior

Server reports OMC version.

Actual behavior

Exception is thrown on the server:

INFO [pool-1-thread-1] (OMCAdapter.java:57) - Requesting OMC Version
DEBUG [pool-1-thread-1] (ZeroMQClient.java:68) - sendExpression: getVersion() returned "OMCompiler v1.17.0-dev.344+gc8233fa62a"
DEBUG [pool-1-thread-1] (ZeroMQClient.java:80) - receiving errors returned: ""
DEBUG [pool-1-thread-1] (OMCInterface.java:112) - calling getVersion() returned: "OMCompiler v1.17.0-dev.344+gc8233fa62a"
Jun 28, 2021 3:21:29 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SEVERE: Internal error: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
        at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
        at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
        at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
        at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
        at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
        at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
        ... 11 more
Caused by: java.lang.IllegalStateException: No match found
        at java.base/java.util.regex.Matcher.group(Matcher.java:645)
        at version.Version.extractNumbers(Version.java:121)
        at version.OMVersion.parseVersion(OMVersion.java:35)
        at version.Version.<init>(Version.java:42)
        at version.SemanticVersion.<init>(SemanticVersion.java:40)
        at version.OMVersion.<init>(OMVersion.java:29)
        at omc.corba.OMCInterface.getVersion(OMCInterface.java:192)
        at Server.Compiler.OMCAdapter.getCompilerVersion(OMCAdapter.java:58)
        at Server.MopeModelicaService.getCompilerVersion(MopeModelicaService.java:42)
        ... 16 more

Speculations about cause

The omc-java-api does not seem to be equipped to deal with development versions of OpenModelica (like OMCompiler v1.17.0-dev.344+gc8233fa62a instead of OMCompiler v1.17.0). This should be as simple as replacing the regex used to parse the version number. For a regex that works fine with development versions (as far as I have tested it), see version parsing in MoST.jl.

CSchoel commented 3 years ago

To fix this issue, please fork https://github.com/THM-MoTE/omc-java-api and create a pull request in the original repo.

CSchoel commented 3 years ago

This is now fixed in omc-java-api v0.3.6. The branch feature/sonarQube already includes the updated version, since it needs this fix.