From fa6ac9f2aa503922224c14c290206bcc115630ff Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Fri, 4 May 2007 18:49:56 +0000 Subject: [PATCH] Java test client/server fixes git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665104 13f79535-47bb-0310-9956-ffa450edef68 --- test/java/src/TestClient.java | 14 +++++++++----- test/java/src/TestServer.java | 7 ++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/test/java/src/TestClient.java b/test/java/src/TestClient.java index 3c8d8b33..8b1cc104 100644 --- a/test/java/src/TestClient.java +++ b/test/java/src/TestClient.java @@ -71,7 +71,7 @@ public class TestClient { } TBinaryProtocol binaryProtocol = - new TBinaryProtocol(transport); + new TBinaryProtocol(transport, false, false); ThriftTest.Client testClient = new ThriftTest.Client(binaryProtocol); @@ -330,15 +330,19 @@ public class TestClient { System.out.print(k2 + " => {"); AbstractMap userMap = v2.userMap; System.out.print("{"); - for (int k3 : userMap.keySet()) { - System.out.print(k3 + " => " + userMap.get(k3) + ", "); + if (userMap != null) { + for (int k3 : userMap.keySet()) { + System.out.print(k3 + " => " + userMap.get(k3) + ", "); + } } System.out.print("}, "); ArrayList xtructs = v2.xtructs; System.out.print("{"); - for (Xtruct x : xtructs) { - System.out.print("{" + "\"" + x.string_thing + "\", " + x.byte_thing + ", " + x.i32_thing + ", "+ x.i64_thing + "}, "); + if (xtructs != null) { + for (Xtruct x : xtructs) { + System.out.print("{" + "\"" + x.string_thing + "\", " + x.byte_thing + ", " + x.i32_thing + ", "+ x.i64_thing + "}, "); + } } System.out.print("}"); diff --git a/test/java/src/TestServer.java b/test/java/src/TestServer.java index 6f1643e2..a4c4a376 100644 --- a/test/java/src/TestServer.java +++ b/test/java/src/TestServer.java @@ -3,6 +3,7 @@ package com.facebook.thrift.test; import com.facebook.thrift.TException; import com.facebook.thrift.protocol.TBinaryProtocol; import com.facebook.thrift.protocol.TProtocol; +import com.facebook.thrift.protocol.TProtocolFactory; import com.facebook.thrift.server.TServer; import com.facebook.thrift.server.TSimpleServer; import com.facebook.thrift.server.TThreadPoolServer; @@ -250,13 +251,17 @@ public class TestServer { TServerSocket tServerSocket = new TServerSocket(port); + // Protocol factory + TProtocolFactory tProtocolFactory = + new TBinaryProtocol.Factory(true, true); + TServer serverEngine; // Simple Server // serverEngine = new TSimpleServer(testProcessor, tServerSocket); // ThreadPool Server - serverEngine = new TThreadPoolServer(testProcessor, tServerSocket); + serverEngine = new TThreadPoolServer(testProcessor, tServerSocket, tProtocolFactory); // Run it System.out.println("Starting the server on port " + port + "..."); -- 2.17.1