Skip to content

Commit

Permalink
Merge pull request #380 from apache/refactoring/379-Clean-up-code
Browse files Browse the repository at this point in the history
Issue #379: Clean up code
  • Loading branch information
reckart authored Sep 4, 2024
2 parents c2e7215 + 7270128 commit 1994048
Show file tree
Hide file tree
Showing 561 changed files with 9,083 additions and 10,378 deletions.
46 changes: 23 additions & 23 deletions jVinci/src/main/java/org/apache/vinci/debug/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
* This is JDK1.3 legacy as this functionality is now provided natively by Java 1.4.
*/
public class Debug {
static private volatile boolean log_messages = true;
private static volatile boolean log_messages = true;

static private volatile boolean log_exceptions = true;
private static volatile boolean log_exceptions = true;

static private boolean output_thread_name = false;
private static boolean output_thread_name = false;

static private PrintStream debugStream = System.err;
private static PrintStream debugStream = System.err;

static private DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT,
private static DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.SHORT, Locale.ENGLISH);

static private Date now = new Date();
private static Date now = new Date();

/**
* This utility class not meant to be instantiated.
Expand All @@ -57,7 +57,7 @@ private Debug() {
* @param w
* The stream where debug output will be directed.
*/
synchronized static public void setDebuggingStream(PrintStream w) {
public static synchronized void setDebuggingStream(PrintStream w) {
debugStream = w;
}

Expand All @@ -66,7 +66,7 @@ synchronized static public void setDebuggingStream(PrintStream w) {
*
* @return The stream currently used for debug output.
*/
synchronized static public PrintStream getDebuggingStream() {
public static synchronized PrintStream getDebuggingStream() {
return debugStream;
}

Expand All @@ -76,7 +76,7 @@ synchronized static public PrintStream getDebuggingStream() {
* @param on
* Whether or not printed debug messages will go to the log.
*/
synchronized static public void setLogMessages(boolean on) {
public static synchronized void setLogMessages(boolean on) {
log_messages = on;
if (on) {
Debug.p("vinci.debug.Debug", "Message logging turned ON.");
Expand All @@ -88,7 +88,7 @@ synchronized static public void setLogMessages(boolean on) {
*
* @return true if message logging is enabled
*/
synchronized static public boolean getLogMessages() {
public static synchronized boolean getLogMessages() {
return log_messages;
}

Expand All @@ -98,7 +98,7 @@ synchronized static public boolean getLogMessages() {
* @param on
* Whtehr or not reported exceptions will be directed to the log.
*/
synchronized static public void setLogExceptions(boolean on) {
public static synchronized void setLogExceptions(boolean on) {
log_exceptions = on;
Debug.p("vinci.debug.Debug", "Exception logging turned " + ((on) ? "ON" : "OFF"));
}
Expand All @@ -108,7 +108,7 @@ synchronized static public void setLogExceptions(boolean on) {
*
* @return true if message logging is enabled
*/
synchronized static public boolean getLogExceptions() {
public static synchronized boolean getLogExceptions() {
return log_messages;
}

Expand All @@ -118,7 +118,7 @@ synchronized static public boolean getLogExceptions() {
* @param on
* Whether or not the thread name will appear in the output.
*/
synchronized static public void setThreadNameOutput(boolean on) {
public static synchronized void setThreadNameOutput(boolean on) {
output_thread_name = on;
}

Expand All @@ -133,7 +133,7 @@ synchronized static public void setThreadNameOutput(boolean on) {
*
* @pre e != null
*/
synchronized static public void reportException(Throwable e, String message) {
public static synchronized void reportException(Throwable e, String message) {
if (log_exceptions) {
printDebuggingMessage("====================================");
debugStream.println("(WARNING) Unexpected exception: " + message);
Expand All @@ -151,7 +151,7 @@ synchronized static public void reportException(Throwable e, String message) {
*
* @pre e != null
*/
synchronized static public void reportException(Throwable e) {
public static synchronized void reportException(Throwable e) {
if (log_exceptions) {
printDebuggingMessage("====================================");
debugStream.println("(WARNING) Unexpected exception: ");
Expand All @@ -169,7 +169,7 @@ synchronized static public void reportException(Throwable e) {
* The message to report.
* @return The string provided as an argument (to support log chaining).
*/
synchronized static public String printDebuggingMessage(String message) {
public static synchronized String printDebuggingMessage(String message) {
if (log_messages) {
now.setTime(System.currentTimeMillis());
if (output_thread_name) {
Expand All @@ -192,7 +192,7 @@ synchronized static public String printDebuggingMessage(String message) {
* @param message
* The message to log.
*/
synchronized static public void printDebuggingMessage(String location, String message) {
public static synchronized void printDebuggingMessage(String location, String message) {
if (log_messages) {
now.setTime(System.currentTimeMillis());
if (output_thread_name) {
Expand All @@ -211,7 +211,7 @@ synchronized static public void printDebuggingMessage(String location, String me
* -
* @return -
*/
static public String p(String message) {
public static String p(String message) {
return printDebuggingMessage(message);
}

Expand All @@ -223,7 +223,7 @@ static public String p(String message) {
* @param message
* -
*/
static public void p(String location, String message) {
public static void p(String location, String message) {
printDebuggingMessage(location, message);
}

Expand All @@ -236,7 +236,7 @@ static public void p(String location, String message) {
* @exception AssertionFailedException
* thrown if the method parameter is false.
*/
static public void Assert(boolean check) throws AssertionFailedException {
public static void Assert(boolean check) throws AssertionFailedException {
if (!check) {
throw new AssertionFailedException("no message");
}
Expand All @@ -253,7 +253,7 @@ static public void Assert(boolean check) throws AssertionFailedException {
* @exception AssertionFailedException
* thrown if the condition evaluates to false.
*/
static public void Assert(boolean check, String message) throws AssertionFailedException {
public static void Assert(boolean check, String message) throws AssertionFailedException {
if (!check) {
throw new AssertionFailedException(message);
}
Expand All @@ -267,7 +267,7 @@ static public void Assert(boolean check, String message) throws AssertionFailedE
* @param e
* The exception which will be logged as a fatal error.
*/
synchronized static void reportFatalException(Throwable e) {
static synchronized void reportFatalException(Throwable e) {
if (log_exceptions) {
printDebuggingMessage("====================================");
debugStream.println("(FATAL ERROR) Unexpected exception: ");
Expand All @@ -280,7 +280,7 @@ synchronized static void reportFatalException(Throwable e) {
* Make sure any messages are flushed to the stream. Printing debug messages does not flush the
* stream automatically, though reporting exceptions does.
*/
synchronized static public void flush() {
public static synchronized void flush() {
debugStream.flush();
}

Expand Down
16 changes: 8 additions & 8 deletions jVinci/src/main/java/org/apache/vinci/transport/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
*/
public class BaseClient {

static public final int DEFAULT_SOCKET_TIMEOUT = 120000;
public static final int DEFAULT_SOCKET_TIMEOUT = 120000;

static public final int DEFAULT_CONNECT_TIMEOUT = 30000;
public static final int DEFAULT_CONNECT_TIMEOUT = 30000;

private String host = null;

Expand Down Expand Up @@ -591,7 +591,7 @@ public KeyValuePair getHeader() {
* @throws ServiceException
* -
*/
static public Transportable sendAndReceive(Transportable in, String host_name, int p,
public static Transportable sendAndReceive(Transportable in, String host_name, int p,
TransportableFactory f) throws IOException, ServiceException {
BaseClient tempClient = new BaseClient(host_name, p, f);
tempClient.setRetry(false);
Expand Down Expand Up @@ -626,7 +626,7 @@ static public Transportable sendAndReceive(Transportable in, String host_name, i
* @throws ServiceException
* -
*/
static public Transportable sendAndReceive(Transportable in, String host_name, int p,
public static Transportable sendAndReceive(Transportable in, String host_name, int p,
TransportableFactory f, int socket_timeout) throws IOException, ServiceException {
BaseClient tempClient = new BaseClient(host_name, p, f);
tempClient.setSocketTimeout(socket_timeout);
Expand Down Expand Up @@ -665,7 +665,7 @@ static public Transportable sendAndReceive(Transportable in, String host_name, i
* @throws ServiceException
* -
*/
static public Transportable sendAndReceive(Transportable in, String host_name, int p,
public static Transportable sendAndReceive(Transportable in, String host_name, int p,
TransportableFactory f, int socket_timeout, int connect_timeout)
throws IOException, ServiceException {
BaseClient tempClient = new BaseClient(host_name, p, f, connect_timeout);
Expand Down Expand Up @@ -698,7 +698,7 @@ static public Transportable sendAndReceive(Transportable in, String host_name, i
* @throws ServiceException
* -
*/
static public VinciFrame rpc(Transportable in, String host_name, int p)
public static VinciFrame rpc(Transportable in, String host_name, int p)
throws IOException, ServiceException {
return (VinciFrame) sendAndReceive(in, host_name, p, VinciFrame.getVinciFrameFactory());
}
Expand All @@ -725,7 +725,7 @@ static public VinciFrame rpc(Transportable in, String host_name, int p)
* @throws ServiceException
* -
*/
static public VinciFrame rpc(Transportable in, String host_name, int p, int socket_timeout)
public static VinciFrame rpc(Transportable in, String host_name, int p, int socket_timeout)
throws IOException, ServiceException {
return (VinciFrame) sendAndReceive(in, host_name, p, VinciFrame.getVinciFrameFactory(),
socket_timeout);
Expand Down Expand Up @@ -755,7 +755,7 @@ static public VinciFrame rpc(Transportable in, String host_name, int p, int sock
* @throws ServiceException
* -
*/
static public VinciFrame rpc(Transportable in, String host_name, int p, int socket_timeout,
public static VinciFrame rpc(Transportable in, String host_name, int p, int socket_timeout,
int connect_timeout) throws IOException, ServiceException {
return (VinciFrame) sendAndReceive(in, host_name, p, VinciFrame.getVinciFrameFactory(),
socket_timeout, connect_timeout);
Expand Down
10 changes: 5 additions & 5 deletions jVinci/src/main/java/org/apache/vinci/transport/BaseServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
*/
public class BaseServer {

static private final int DEFAULT_SOCKET_TIMEOUT = 60000; // one minute.
private static final int DEFAULT_SOCKET_TIMEOUT = 60000; // one minute.

static private final int DEFAULT_MAX_POOL_SIZE = 20;
private static final int DEFAULT_MAX_POOL_SIZE = 20;

static private final int SERVER_SOCKET_TIMEOUT = 1000;
private static final int SERVER_SOCKET_TIMEOUT = 1000;

volatile private boolean shutdown;
private volatile boolean shutdown;

volatile private boolean isServing;
private volatile boolean isServing;

private ServerSocket serverSocket;

Expand Down
8 changes: 4 additions & 4 deletions jVinci/src/main/java/org/apache/vinci/transport/Frame.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
*/
public abstract class Frame extends FrameComponent implements Transportable {

static private final String XML_INDENT = " ";
private static final String XML_INDENT = " ";

static private FrameTransporter parser = new XTalkTransporter();
private static FrameTransporter parser = new XTalkTransporter();

protected Frame() {
}
Expand All @@ -69,7 +69,7 @@ protected Frame() {
* @param transporter
* The new marshaller to plug in.
*/
static public void setFrameTransporter(FrameTransporter transporter) {
public static void setFrameTransporter(FrameTransporter transporter) {
parser = transporter;
}

Expand All @@ -78,7 +78,7 @@ static public void setFrameTransporter(FrameTransporter transporter) {
*
* @return The currently installed document marshaller.
*/
static public FrameTransporter getFrameTransporter() {
public static FrameTransporter getFrameTransporter() {
return parser;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class FrameLeaf extends FrameComponent {
* If you call toString() on a FrameLeaf which contains binary data, you get this string as the
* result.
*/
static public final String NOT_UTF8_ERROR = "*** ERROR: Data not utf8 ***";
public static final String NOT_UTF8_ERROR = "*** ERROR: Data not utf8 ***";

private final byte[] data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private VinciClient getClientFromPool() throws IOException {
/**
* Release a client that has been obtained from getClientFromPool.
*/
synchronized private void releaseClient(VinciClient c) {
private synchronized void releaseClient(VinciClient c) {
if (closed) {
--availableClientsStartIndex;
this.notify();
Expand Down
14 changes: 7 additions & 7 deletions jVinci/src/main/java/org/apache/vinci/transport/VinciClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public int getInstance() {
* @pre service_name != null
* @pre factory != null
*/
static public Transportable sendAndReceive(Transportable in, String service_name,
public static Transportable sendAndReceive(Transportable in, String service_name,
TransportableFactory factory)
throws IOException, ServiceException, ServiceDownException, VNSException {
return VinciContext.getGlobalContext().sendAndReceive(in, service_name, factory);
Expand Down Expand Up @@ -331,7 +331,7 @@ static public Transportable sendAndReceive(Transportable in, String service_name
* @pre factory != null
* @pre socket_timeout ≥ 0
*/
static public Transportable sendAndReceive(Transportable in, String service_name,
public static Transportable sendAndReceive(Transportable in, String service_name,
TransportableFactory factory, int socket_timeout) throws IOException, ServiceException {
return VinciContext.getGlobalContext().sendAndReceive(in, service_name, factory,
socket_timeout);
Expand Down Expand Up @@ -364,7 +364,7 @@ static public Transportable sendAndReceive(Transportable in, String service_name
* @pre factory != null
* @pre socket_timeout ≥ 0
*/
static public Transportable sendAndReceive(Transportable in, String service_name,
public static Transportable sendAndReceive(Transportable in, String service_name,
TransportableFactory factory, int socket_timeout, int connect_timeout)
throws IOException, ServiceException {
return VinciContext.getGlobalContext().sendAndReceive(in, service_name, factory, socket_timeout,
Expand Down Expand Up @@ -590,7 +590,7 @@ protected boolean isSocketKeepAliveEnabled() {
* @pre in != null
* @pre service_name != null
*/
static public VinciFrame rpc(Transportable in, String service_name)
public static VinciFrame rpc(Transportable in, String service_name)
throws IOException, ServiceException, ServiceDownException, VNSException {
return VinciContext.getGlobalContext().rpc(in, service_name);
}
Expand Down Expand Up @@ -622,7 +622,7 @@ static public VinciFrame rpc(Transportable in, String service_name)
* @throws VNSException
* -
*/
static public VinciFrame rpc(Transportable in, String service_name, int timeout)
public static VinciFrame rpc(Transportable in, String service_name, int timeout)
throws IOException, ServiceException, ServiceDownException, VNSException {
return VinciContext.getGlobalContext().rpc(in, service_name, timeout);
}
Expand Down Expand Up @@ -657,13 +657,13 @@ static public VinciFrame rpc(Transportable in, String service_name, int timeout)
* @throws VNSException
* -
*/
static public VinciFrame rpc(Transportable in, String service_name, int timeout,
public static VinciFrame rpc(Transportable in, String service_name, int timeout,
int connect_timeout)
throws IOException, ServiceException, ServiceDownException, VNSException {
return VinciContext.getGlobalContext().rpc(in, service_name, timeout, connect_timeout);
}

static public void main(String[] args) throws Exception {
public static void main(String[] args) throws Exception {
Frame ping = new VinciFrame().fadd(TransportConstants.PING_KEY, "hi");
System.out.println(VinciClient.rpc(ping, args[0]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Transportable makeTransportable() {
*
* @return -
*/
static public TransportableFactory getVinciFrameFactory() {
public static TransportableFactory getVinciFrameFactory() {
return vinciFrameFactory;
}

Expand Down
Loading

0 comments on commit 1994048

Please sign in to comment.