File tree Expand file tree Collapse file tree 3 files changed +19
-13
lines changed
main/java/com/baeldung/thrift
test/java/com/baeldung/thrift Expand file tree Collapse file tree 3 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 11package com .baeldung .thrift ;
22
3+ import org .apache .thrift .transport .TTransportException ;
4+
35public 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 }
Original file line number Diff line number Diff line change 66import org .apache .thrift .server .TSimpleServer ;
77import org .apache .thrift .transport .TServerSocket ;
88import org .apache .thrift .transport .TServerTransport ;
9+ import org .apache .thrift .transport .TTransportException ;
910
1011public 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 () {
Original file line number Diff line number Diff line change 11package com .baeldung .thrift ;
22
3+ import org .apache .thrift .transport .TTransportException ;
34import org .junit .After ;
45import org .junit .Assert ;
56import 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 );
You can’t perform that action at this time.
0 commit comments