Skip to content

Commit

Permalink
[RM-84612] Corrected after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Smirnov-Exactpro committed Feb 13, 2024
1 parent 4cfdb52 commit ec60f10
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ jar {
archivesBaseName = applicationName
manifest {
attributes('Specification-Title': 'TH2 Hand')
attributes('Main-Class': 'com.exactpro.th2.hand.Application')
attributes("Class-Path": configurations.compileClasspath.collect { "lib/" + it.getName() }.join(' '))
attributes(
'Created-By': "${System.getProperty('java.version')} (${System.getProperty('java.vendor')})",
'Specification-Title': '',
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/exactpro/th2/hand/HandServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void start() throws IOException {
server.start();
LOGGER.info("Server started, listening on port {}", server.getPort());
} else {
throw new IllegalStateException(getClass().getSimpleName() + " was started once");
throw new IllegalStateException(getClass().getSimpleName() + " is already started");
}
}

Expand Down Expand Up @@ -94,6 +94,7 @@ public void close() throws InterruptedException {
Thread thread = watcher.get();
if (thread != null && !thread.isInterrupted()) {
thread.interrupt();
thread.join(30_000);
}
}
}
20 changes: 2 additions & 18 deletions src/main/java/com/exactpro/th2/hand/services/HandBaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,13 @@ public void dispose() {
}
}

/**
* @throws RhConfigurationException
*/
@SuppressWarnings("JavadocDeclaration")
@Override
public RhSessionID register(RhTargetServer targetServer) {
try {
String sessionId = messageHandler.getRhConnectionManager().createSessionHandler(targetServer.getTarget()).getId();
return RhSessionID.newBuilder().setId(sessionId).setSessionAlias(messageHandler.getConfig().getSessionAlias()).build();
} catch (RhConfigurationException e) {
sneakyThrow(e);
return null;
throw new HandRuntimeException(e.getMessage(), e);
}
}

Expand All @@ -123,28 +118,17 @@ public Empty unregister(RhSessionID input, Map<String, String> properties) {
return unregister(input);
}

/**
* @throws IOException
*/
@SuppressWarnings("JavadocDeclaration")
@Override
public RhBatchResponse executeRhActionsBatch(RhActionsBatch request) {
try {
return messageHandler.handleActionsBatchRequest(request);
} catch (IOException e) {
sneakyThrow(e);
return null;
throw new HandRuntimeException(e.getMessage(), e);
}
}

@Override
public RhBatchResponse executeRhActionsBatch(RhActionsBatch input, Map<String, String> properties) {
return executeRhActionsBatch(input);
}

// This hack is used to avoid wrapping cause error
private static <E extends Throwable> void sneakyThrow(Throwable e) throws E {
//noinspection unchecked
throw (E) e;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.exactpro.th2.hand.services

class HandRuntimeException(message: String, cause: Throwable) : RuntimeException(message, cause)

0 comments on commit ec60f10

Please sign in to comment.