From 0096b20883acf08c46389c8d232a49d8886074dc Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Fri, 13 Mar 2009 00:28:06 +0000 Subject: [PATCH] THRIFT-366. java: Lots of little warnings in java library This cleans up imports, adds generic arguments where necessary, and puts OverloadNonblockingServer into the right package. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@753072 13f79535-47bb-0310-9956-ffa450edef68 --- .../thrift/meta_data/FieldMetaData.java | 6 +- .../thrift/meta_data/StructMetaData.java | 6 +- .../org/apache/thrift/server/THsHaServer.java | 22 ++------ .../thrift/server/TNonblockingServer.java | 55 +++++++------------ .../transport/TNonblockingServerSocket.java | 6 +- .../thrift/transport/TNonblockingSocket.java | 6 +- .../org/apache/thrift/test/IdentityTest.java | 27 +++++---- .../org/apache/thrift/test/JSONProtoTest.java | 18 +++--- .../org/apache/thrift/test/JavaBeansTest.java | 6 +- .../org/apache/thrift/test/MetaDataTest.java | 8 +-- .../test/OverloadNonblockingServer.java | 19 +------ .../thrift/test/TCompactProtocolTest.java | 25 +++++++-- .../thrift/test/TestNonblockingServer.java | 22 +------- .../org/apache/thrift/test/TestServer.java | 27 +++++---- 14 files changed, 103 insertions(+), 150 deletions(-) diff --git a/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java b/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java index efb7630c3..95c2b48ff 100644 --- a/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java +++ b/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java @@ -13,10 +13,10 @@ public class FieldMetaData implements java.io.Serializable { public final String fieldName; public final byte requirementType; public final FieldValueMetaData valueMetaData; - private static Map, Map> structMap; + private static Map, Map> structMap; static { - structMap = new HashMap, Map>(); + structMap = new HashMap, Map>(); } public FieldMetaData(String name, byte req, FieldValueMetaData vMetaData){ @@ -25,7 +25,7 @@ public class FieldMetaData implements java.io.Serializable { this.valueMetaData = vMetaData; } - public static void addStructMetaDataMap(Class sClass, Map map){ + public static void addStructMetaDataMap(Class sClass, Map map){ structMap.put(sClass, map); } diff --git a/lib/java/src/org/apache/thrift/meta_data/StructMetaData.java b/lib/java/src/org/apache/thrift/meta_data/StructMetaData.java index 8fd6ce0e3..1d1193100 100644 --- a/lib/java/src/org/apache/thrift/meta_data/StructMetaData.java +++ b/lib/java/src/org/apache/thrift/meta_data/StructMetaData.java @@ -1,9 +1,11 @@ package org.apache.thrift.meta_data; +import org.apache.thrift.TBase; + public class StructMetaData extends FieldValueMetaData { - public final Class structClass; + public final Class structClass; - public StructMetaData(byte type, Class sClass){ + public StructMetaData(byte type, Class sClass){ super(type); this.structClass = sClass; } diff --git a/lib/java/src/org/apache/thrift/server/THsHaServer.java b/lib/java/src/org/apache/thrift/server/THsHaServer.java index ccb4a8e57..cdca92367 100644 --- a/lib/java/src/org/apache/thrift/server/THsHaServer.java +++ b/lib/java/src/org/apache/thrift/server/THsHaServer.java @@ -1,27 +1,17 @@ package org.apache.thrift.server; -import org.apache.thrift.TException; -import org.apache.thrift.TProcessor; -import org.apache.thrift.TProcessorFactory; -import org.apache.thrift.protocol.TProtocol; -import org.apache.thrift.protocol.TProtocolFactory; -import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.transport.TNonblockingServerTransport; -import org.apache.thrift.transport.TTransport; -import org.apache.thrift.transport.TFramedTransport; -import org.apache.thrift.transport.TNonblockingTransport; -import org.apache.thrift.transport.TTransportException; -import org.apache.thrift.transport.TTransportFactory; - import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import java.io.IOException; +import org.apache.thrift.TProcessor; +import org.apache.thrift.TProcessorFactory; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TProtocolFactory; +import org.apache.thrift.transport.TFramedTransport; +import org.apache.thrift.transport.TNonblockingServerTransport; /** * An extension of the TNonblockingServer to a Half-Sync/Half-Async server. diff --git a/lib/java/src/org/apache/thrift/server/TNonblockingServer.java b/lib/java/src/org/apache/thrift/server/TNonblockingServer.java index 21859807a..e5f49df33 100644 --- a/lib/java/src/org/apache/thrift/server/TNonblockingServer.java +++ b/lib/java/src/org/apache/thrift/server/TNonblockingServer.java @@ -1,44 +1,31 @@ package org.apache.thrift.server; -import org.apache.thrift.TException; -import org.apache.thrift.TProcessor; -import org.apache.thrift.TProcessorFactory; -import org.apache.thrift.protocol.TProtocol; -import org.apache.thrift.protocol.TProtocolFactory; -import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.transport.TNonblockingServerTransport; -import org.apache.thrift.transport.TIOStreamTransport; -import org.apache.thrift.transport.TTransport; -import org.apache.thrift.transport.TFramedTransport; -import org.apache.thrift.transport.TNonblockingTransport; -import org.apache.thrift.transport.TTransportException; -import org.apache.thrift.transport.TTransportFactory; -import org.apache.thrift.TByteArrayOutputStream; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.Iterator; -import java.util.HashMap; -import java.util.Set; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.spi.SelectorProvider; import java.util.HashSet; - +import java.util.Iterator; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import java.io.IOException; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.nio.ByteBuffer; -import java.nio.channels.Selector; -import java.nio.channels.SelectionKey; -import java.nio.channels.spi.SelectorProvider; -import java.nio.channels.CancelledKeyException; -import java.nio.channels.ClosedChannelException; +import org.apache.thrift.TByteArrayOutputStream; +import org.apache.thrift.TException; +import org.apache.thrift.TProcessor; +import org.apache.thrift.TProcessorFactory; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TProtocol; +import org.apache.thrift.protocol.TProtocolFactory; +import org.apache.thrift.transport.TFramedTransport; +import org.apache.thrift.transport.TIOStreamTransport; +import org.apache.thrift.transport.TNonblockingServerTransport; +import org.apache.thrift.transport.TNonblockingTransport; +import org.apache.thrift.transport.TTransport; +import org.apache.thrift.transport.TTransportException; /** * A nonblocking TServer implementation. This allows for fairness amongst all diff --git a/lib/java/src/org/apache/thrift/transport/TNonblockingServerSocket.java b/lib/java/src/org/apache/thrift/transport/TNonblockingServerSocket.java index 9e1af698c..b03f80ed6 100644 --- a/lib/java/src/org/apache/thrift/transport/TNonblockingServerSocket.java +++ b/lib/java/src/org/apache/thrift/transport/TNonblockingServerSocket.java @@ -4,14 +4,12 @@ package org.apache.thrift.transport; import java.io.IOException; import java.net.InetSocketAddress; import java.net.ServerSocket; -import java.net.Socket; import java.net.SocketException; - +import java.nio.channels.ClosedChannelException; +import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; -import java.nio.channels.SelectionKey; -import java.nio.channels.ClosedChannelException; /** * Wrapper around ServerSocketChannel diff --git a/lib/java/src/org/apache/thrift/transport/TNonblockingSocket.java b/lib/java/src/org/apache/thrift/transport/TNonblockingSocket.java index b14b84b1b..7f408dc4b 100644 --- a/lib/java/src/org/apache/thrift/transport/TNonblockingSocket.java +++ b/lib/java/src/org/apache/thrift/transport/TNonblockingSocket.java @@ -1,17 +1,13 @@ package org.apache.thrift.transport; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.IOException; -import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; - import java.nio.ByteBuffer; -import java.nio.channels.SocketChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; /** * Socket implementation of the TTransport interface. To be commented soon! diff --git a/lib/java/test/org/apache/thrift/test/IdentityTest.java b/lib/java/test/org/apache/thrift/test/IdentityTest.java index afc114a65..584bf1453 100644 --- a/lib/java/test/org/apache/thrift/test/IdentityTest.java +++ b/lib/java/test/org/apache/thrift/test/IdentityTest.java @@ -1,24 +1,23 @@ package org.apache.thrift.test; // Generated code -import thrift.test.*; - -import org.apache.thrift.TSerializer; -import org.apache.thrift.TDeserializer; -import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.protocol.TSimpleJSONProtocol; - -import java.util.Map; -import java.util.HashMap; -import java.util.Set; -import java.util.HashSet; -import java.util.List; -import java.util.ArrayList; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; + +import org.apache.thrift.TDeserializer; +import org.apache.thrift.TSerializer; +import org.apache.thrift.protocol.TBinaryProtocol; + +import thrift.test.Bonk; +import thrift.test.HolyMoley; +import thrift.test.Nesting; +import thrift.test.OneOfEach; /** * diff --git a/lib/java/test/org/apache/thrift/test/JSONProtoTest.java b/lib/java/test/org/apache/thrift/test/JSONProtoTest.java index 4dba33f48..c955bc053 100644 --- a/lib/java/test/org/apache/thrift/test/JSONProtoTest.java +++ b/lib/java/test/org/apache/thrift/test/JSONProtoTest.java @@ -1,17 +1,19 @@ package org.apache.thrift.test; // Generated code -import thrift.test.*; - -import org.apache.thrift.transport.TMemoryBuffer; -import org.apache.thrift.protocol.TJSONProtocol; - -import java.util.Map; +import java.util.ArrayList; import java.util.HashMap; -import java.util.Set; import java.util.HashSet; import java.util.List; -import java.util.ArrayList; + +import org.apache.thrift.protocol.TJSONProtocol; +import org.apache.thrift.transport.TMemoryBuffer; + +import thrift.test.Base64; +import thrift.test.Bonk; +import thrift.test.HolyMoley; +import thrift.test.Nesting; +import thrift.test.OneOfEach; /** * Tests for the Java implementation of TJSONProtocol. Mirrors the C++ version diff --git a/lib/java/test/org/apache/thrift/test/JavaBeansTest.java b/lib/java/test/org/apache/thrift/test/JavaBeansTest.java index 707a4c257..ec88029a1 100644 --- a/lib/java/test/org/apache/thrift/test/JavaBeansTest.java +++ b/lib/java/test/org/apache/thrift/test/JavaBeansTest.java @@ -40,10 +40,10 @@ public class JavaBeansTest { // Everything is set ooe.set_a_bite((byte) 1); ooe.set_base64("bytes".getBytes()); - ooe.set_byte_list(new LinkedList()); + ooe.set_byte_list(new LinkedList()); ooe.set_double_precision(1); - ooe.set_i16_list(new LinkedList()); - ooe.set_i64_list(new LinkedList()); + ooe.set_i16_list(new LinkedList()); + ooe.set_i64_list(new LinkedList()); ooe.set_boolean_field(true); ooe.set_integer16((short) 1); ooe.set_integer32(1); diff --git a/lib/java/test/org/apache/thrift/test/MetaDataTest.java b/lib/java/test/org/apache/thrift/test/MetaDataTest.java index daf9b44cd..f1369dbb7 100644 --- a/lib/java/test/org/apache/thrift/test/MetaDataTest.java +++ b/lib/java/test/org/apache/thrift/test/MetaDataTest.java @@ -14,9 +14,7 @@ import thrift.test.*; public class MetaDataTest { public static void main(String[] args) throws Exception { - CrazyNesting cn = new CrazyNesting(); - Insanity in = new Insanity(); - Map mdMap = cn.metaDataMap; + Map mdMap = CrazyNesting.metaDataMap; // Check for struct fields existence if (mdMap.size() != 3) @@ -53,8 +51,8 @@ public class MetaDataTest { FieldMetaData.getStructMetaDataMap(Insanity.class) == null || FieldMetaData.getStructMetaDataMap(Xtruct.class) == null) throw new RuntimeException("global metadata map doesn't contain an entry for a known struct"); - if (FieldMetaData.getStructMetaDataMap(CrazyNesting.class) != cn.metaDataMap || - FieldMetaData.getStructMetaDataMap(Insanity.class) != in.metaDataMap) + if (FieldMetaData.getStructMetaDataMap(CrazyNesting.class) != CrazyNesting.metaDataMap || + FieldMetaData.getStructMetaDataMap(Insanity.class) != Insanity.metaDataMap) throw new RuntimeException("global metadata map contains wrong entry for a loaded struct"); } } diff --git a/lib/java/test/org/apache/thrift/test/OverloadNonblockingServer.java b/lib/java/test/org/apache/thrift/test/OverloadNonblockingServer.java index 49b750915..809d53217 100644 --- a/lib/java/test/org/apache/thrift/test/OverloadNonblockingServer.java +++ b/lib/java/test/org/apache/thrift/test/OverloadNonblockingServer.java @@ -1,23 +1,8 @@ -package org.apache.thrift; +package org.apache.thrift.test; -import thrift.test.*; - -import org.apache.thrift.TApplicationException; -import org.apache.thrift.TSerializer; -import org.apache.thrift.transport.TTransport; -import org.apache.thrift.transport.TSocket; -import org.apache.thrift.transport.TFramedTransport; -import org.apache.thrift.transport.TTransportException; import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.protocol.TSimpleJSONProtocol; - -import java.util.Map; -import java.util.HashMap; -import java.util.Set; -import java.util.HashSet; -import java.util.List; -import java.util.ArrayList; +import org.apache.thrift.transport.TSocket; public class OverloadNonblockingServer { diff --git a/lib/java/test/org/apache/thrift/test/TCompactProtocolTest.java b/lib/java/test/org/apache/thrift/test/TCompactProtocolTest.java index b8df71db3..88a55e251 100755 --- a/lib/java/test/org/apache/thrift/test/TCompactProtocolTest.java +++ b/lib/java/test/org/apache/thrift/test/TCompactProtocolTest.java @@ -1,14 +1,27 @@ package org.apache.thrift.test; -import java.util.*; +import java.util.Arrays; +import java.util.List; -import org.apache.thrift.transport.*; -import org.apache.thrift.server.*; -import org.apache.thrift.protocol.*; -import org.apache.thrift.*; +import org.apache.thrift.TBase; +import org.apache.thrift.TException; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TCompactProtocol; +import org.apache.thrift.protocol.TField; +import org.apache.thrift.protocol.TMessage; +import org.apache.thrift.protocol.TMessageType; +import org.apache.thrift.protocol.TProtocol; +import org.apache.thrift.protocol.TProtocolFactory; +import org.apache.thrift.protocol.TStruct; +import org.apache.thrift.protocol.TType; +import org.apache.thrift.transport.TMemoryBuffer; -import thrift.test.*; +import thrift.test.CompactProtoTestStruct; +import thrift.test.HolyMoley; +import thrift.test.Nesting; +import thrift.test.OneOfEach; +import thrift.test.Srv; public class TCompactProtocolTest { diff --git a/lib/java/test/org/apache/thrift/test/TestNonblockingServer.java b/lib/java/test/org/apache/thrift/test/TestNonblockingServer.java index 5df52da46..0c122dbaa 100644 --- a/lib/java/test/org/apache/thrift/test/TestNonblockingServer.java +++ b/lib/java/test/org/apache/thrift/test/TestNonblockingServer.java @@ -1,27 +1,11 @@ package org.apache.thrift.test; -import org.apache.thrift.TException; -import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.protocol.TProtocol; -import org.apache.thrift.protocol.TProtocolFactory; -import org.apache.thrift.server.TServer; -import org.apache.thrift.server.TSimpleServer; -import org.apache.thrift.server.TNonblockingServer; import org.apache.thrift.server.THsHaServer; +import org.apache.thrift.server.TNonblockingServer; +import org.apache.thrift.server.TServer; import org.apache.thrift.transport.TNonblockingServerSocket; -import org.apache.thrift.transport.TNonblockingServerTransport; -import org.apache.thrift.transport.TFramedTransport; -// Generated code -import thrift.test.*; - -import java.net.ServerSocket; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.Set; -import java.util.HashSet; +import thrift.test.ThriftTest; public class TestNonblockingServer extends TestServer { diff --git a/lib/java/test/org/apache/thrift/test/TestServer.java b/lib/java/test/org/apache/thrift/test/TestServer.java index a2f2d2076..989fbe69d 100644 --- a/lib/java/test/org/apache/thrift/test/TestServer.java +++ b/lib/java/test/org/apache/thrift/test/TestServer.java @@ -1,25 +1,24 @@ package org.apache.thrift.test; -import org.apache.thrift.TException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.protocol.TProtocolFactory; import org.apache.thrift.server.TServer; -import org.apache.thrift.server.TSimpleServer; import org.apache.thrift.server.TThreadPoolServer; import org.apache.thrift.transport.TServerSocket; -import org.apache.thrift.transport.TServerTransport; -// Generated code -import thrift.test.*; - -import java.net.ServerSocket; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.Set; -import java.util.HashSet; +import thrift.test.Insanity; +import thrift.test.Numberz; +import thrift.test.ThriftTest; +import thrift.test.Xception; +import thrift.test.Xception2; +import thrift.test.Xtruct; +import thrift.test.Xtruct2; public class TestServer {