Skip to content

Commit f69deec

Browse files
committed
BAEL-598 Removed try-catch block, added throws declaration
1 parent bd6fe72 commit f69deec

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

apache-thrift/src/main/java/com/baeldung/thrift/Application.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.baeldung.thrift;
22

3+
import org.apache.thrift.transport.TTransportException;
4+
35
public class Application {
46

5-
public static void main(String[] args) {
7+
public static void main(String[] args) throws TTransportException {
68
CrossPlatformServiceServer server = new CrossPlatformServiceServer();
79
server.start();
810
}

apache-thrift/src/main/java/com/baeldung/thrift/CrossPlatformServiceServer.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,22 @@
66
import org.apache.thrift.server.TSimpleServer;
77
import org.apache.thrift.transport.TServerSocket;
88
import org.apache.thrift.transport.TServerTransport;
9+
import org.apache.thrift.transport.TTransportException;
910

1011
public class CrossPlatformServiceServer {
1112

1213
private TServer server;
1314

14-
public void start() {
15-
try {
16-
TServerTransport serverTransport = new TServerSocket(9090);
17-
server = new TSimpleServer(new TServer.Args(serverTransport)
18-
.processor(new CrossPlatformService.Processor<>(new CrossPlatformServiceImpl())));
15+
public void start() throws TTransportException {
16+
TServerTransport serverTransport = new TServerSocket(9090);
17+
server = new TSimpleServer(new TServer.Args(serverTransport)
18+
.processor(new CrossPlatformService.Processor<>(new CrossPlatformServiceImpl())));
1919

20-
System.out.print("Starting the server... ");
20+
System.out.print("Starting the server... ");
2121

22-
server.serve();
22+
server.serve();
2323

24-
System.out.println("done.");
25-
} catch (Exception e) {
26-
e.printStackTrace();
27-
}
24+
System.out.println("done.");
2825
}
2926

3027
public void stop() {

apache-thrift/src/test/java/com/baeldung/thrift/CrossPlatformServiceTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.baeldung.thrift;
22

3+
import org.apache.thrift.transport.TTransportException;
34
import org.junit.After;
45
import org.junit.Assert;
56
import org.junit.Before;
@@ -11,7 +12,13 @@ public class CrossPlatformServiceTest {
1112

1213
@Before
1314
public void setUp() {
14-
new Thread(() -> server.start()).start();
15+
new Thread(() -> {
16+
try {
17+
server.start();
18+
} catch (TTransportException e) {
19+
e.printStackTrace();
20+
}
21+
}).start();
1522
try {
1623
// wait for the server start up
1724
Thread.sleep(1000);

0 commit comments

Comments
 (0)