NetXAResource.java

Index Score
org.apache.derby.client.net
Apache Derby

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
LINE_COMMENTNumber of line comments
EXEC_COMMENTSComments in executable code
SIZESize of the file in bytes
LOGICAL_LINESNumber of statements
CYCLOMATICCyclomatic complexity
ELOCEffective lines of code
OPERANDSNumber of operands
LOCLines of code
PROGRAM_LENGTHHalstead program length
OPERATORSNumber of operators
BLOCKSNumber of blocks
LINESNumber of lines in the source file
JAVA0116JAVA0116 Missing javadoc: field 'field'
COMPARISONSNumber of comparison operators
UNIQUE_OPERANDSNumber of unique operands
PROGRAM_VOCABHalstead program vocabulary
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
RETURNSNumber of return points from functions
EXITSProcedure exits
COMMENTSComment lines
INTERFACE_COMPLEXITYInterface complexity
LOOPSNumber of loops
JAVA0177JAVA0177 Variable declaration missing initializer
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0034JAVA0034 Missing braces in if statement
JAVA0040JAVA0040 Switch statement contains N cases (maximum: M)
UNIQUE_OPERATORSNumber of unique operators
NEST_DEPTHMaximum nesting depth
DOC_COMMENTNumber of javadoc comment lines
JAVA0144JAVA0144 Line exceeds maximum M characters
JAVA0143JAVA0143 Synchronized method
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0032JAVA0032 Switch statement missing default
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0264JAVA0264 Integer math in long context - check for overflow
PARAMSNumber of formal parameter declarations
JAVA0123JAVA0123 Use all three components of for loop
JAVA0007JAVA0007 Should not declare public field
JAVA0067JAVA0067 Array descriptor on identifier name
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0145JAVA0145 Tab character used in source file
/* Derby - Class org.apache.derby.client.net.NetXAResource Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /********************************************************************** * * * Component Name = * * Package Name = org.apache.derby.client.net * * Descriptive Name = class implements XAResource * * Status = New code * * Function = Handle XA methods * * List of Classes * - NetXAResource * * Restrictions : None * **********************************************************************/ package org.apache.derby.client.net; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Collections; import java.util.Enumeration; import java.util.LinkedList; import java.util.List; import java.util.Vector; import javax.sql.XAConnection; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; import org.apache.derby.client.ClientXid; import org.apache.derby.client.am.Connection; import org.apache.derby.client.am.SqlException; import org.apache.derby.client.am.ClientMessageId; import org.apache.derby.shared.common.reference.SQLState; public class NetXAResource implements XAResource { public static final int TMTIMEOUT = 0x00000100; public static final int ACTIVE_ONLY = -1; public static final int XA_NULL_XID = -1; // null Xid has Format Id of -1 public static final int INITIAL_CALLINFO_ELEMENTS = 1; public static final int RECOVER_XID_ARRAY_LENGTH = 10; public static final ClientXid nullXid = new ClientXid(); // xaFunction defines, shows which queued XA function is being performed public static final int XAFUNC_NONE = 0; public static final int XAFUNC_COMMIT = 1; public static final int XAFUNC_END = 2; public static final int XAFUNC_FORGET = 3; public static final int XAFUNC_PREPARE = 4; public static final int XAFUNC_RECOVER = 5; public static final int XAFUNC_ROLLBACK = 6; public static final int XAFUNC_START = 7; public static final String XAFUNCSTR_NONE = "No XA Function"; public static final String XAFUNCSTR_COMMIT = "XAResource.commit()"; public static final String XAFUNCSTR_END = "XAResource.end()"; public static final String XAFUNCSTR_FORGET = "XAResource.forget()"; public static final String XAFUNCSTR_PREPARE = "XAResource.prepare()"; public static final String XAFUNCSTR_RECOVER = "XAResource.recover()"; public static final String XAFUNCSTR_ROLLBACK = "XAResource.rollback()"; public static final String XAFUNCSTR_START = "XAResource.start()"; public int nextElement = 0; // XAResources with same RM group list protected static Vector xaResourceSameRMGroup_ = new Vector(); protected int sameRMGroupIndex_ = 0; protected NetXAResource nextSameRM_ = null; protected boolean ignoreMe_ = false; public org.apache.derby.client.am.SqlException exceptionsOnXA = null; XAConnection xaconn_; org.apache.derby.client.net.NetXAConnection netXAConn_; org.apache.derby.client.net.NetConnection conn_; int rmId_; // unique RmId generated by XAConnection // TODO: change to a single callInfo field (not an array) NetXACallInfo callInfoArray_[] = new NetXACallInfo[INITIAL_CALLINFO_ELEMENTS]; int numXACallInfo_ = INITIAL_CALLINFO_ELEMENTS; int connectionCount_ = 1; int activeXATransCount_ = 0; String rmIdx_; // userid in case we need to create a secondary connection String rmIdy_; // password in case we need to create a secondary connection // TODO: remove port and ipaddr_ int port_; // port needed to make secondary connection for recover in DS mode. String ipaddr_; // ip address needed to make secondary connection for recover in DS mode. private List specialRegisters_ = Collections.synchronizedList(new LinkedList()); /** The value of the transaction timeout in seconds. */ private int timeoutSeconds = 0; public NetXAResource(XAConnection xaconn, int rmId, String userId, String password, org.apache.derby.client.net.NetXAConnection conn) { xaconn_ = xaconn; rmId_ = rmId; conn_ = conn.getNetConnection(); netXAConn_ = conn; rmIdx_ = userId; rmIdy_ = password; port_ = conn_.netAgent_.getPort(); ipaddr_ = conn_.netAgent_.socket_.getLocalAddress().getHostAddress(); conn.setNetXAResource(this); // link the primary connection to the first XACallInfo element conn_.currXACallInfoOffset_ = 0; // construct the NetXACallInfo object for the array. for (int i = 0; i < INITIAL_CALLINFO_ELEMENTS; ++i) { callInfoArray_[i] = new NetXACallInfo(null, XAResource.TMNOFLAGS, this, null); } // initialize the first XACallInfo element with the information from the // primary connection callInfoArray_[0].actualConn_ = conn; callInfoArray_[0].currConnection_ = true; callInfoArray_[0].freeEntry_ = false; // ~~~ save conn_ connection variables in callInfoArray_[0] callInfoArray_[0].saveConnectionVariables(); // add this new XAResource to the list of other XAResources for the Same RM initForReuse(); } public void commit(Xid xid, boolean onePhase) throws XAException { NetAgent netAgent = conn_.netAgent_; int rc = XAResource.XA_OK; exceptionsOnXA = null; if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceEntry(this, "commit", xid, onePhase); } if (conn_.isPhysicalConnClosed()) { connectionClosedFailure(); } // update the XACallInfo NetXACallInfo callInfo = callInfoArray_[conn_.currXACallInfoOffset_]; callInfo.xaFlags_ = (onePhase ? XAResource.TMONEPHASE : XAResource.TMNOFLAGS); callInfo.xid_ = xid; callInfo.xaResource_ = this; callInfo.xaRetVal_ = XAResource.XA_OK; // initialize XARETVAL try { netAgent.beginWriteChainOutsideUOW(); netAgent.netConnectionRequest_.writeXaCommit(conn_, xid); netAgent.flowOutsideUOW(); netAgent.netConnectionReply_.readXaCommit(conn_); if (callInfo.xaRetVal_ != XAResource.XA_OK) { // xaRetVal has possible error, format it callInfo.xaFunction_ = XAFUNC_COMMIT; rc = xaRetValErrorAccumSQL(callInfo, rc); callInfo.xaRetVal_ = XAResource.XA_OK; // re-initialize XARETVAL } netAgent.endReadChain(); } catch (SqlException sqle) { rc = XAException.XAER_RMERR; exceptionsOnXA = org.apache.derby.client.am.Utils.accumulateSQLException (sqle, exceptionsOnXA); } finally { conn_.pendingEndXACallinfoOffset_ = -1; // indicate no pending callinfo } if (rc != XAResource.XA_OK) { throwXAException(rc, false); } } /** * Ends the work performed on behalf of a transaction branch. The resource manager dissociates the XA resource from * the transaction branch specified and let the transaction be completed. * <p/> * If TMSUSPEND is specified in flags, the transaction branch is temporarily suspended in incomplete state. The * transaction context is in suspened state and must be resumed via start with TMRESUME specified. * <p/> * If TMFAIL is specified, the portion of work has failed. The resource manager may mark the transaction as * rollback-only * <p/> * If TMSUCCESS is specified, the portion of work has completed successfully. * * @param xid A global transaction identifier that is the same as what was used previously in the start method. * @param flags One of TMSUCCESS, TMFAIL, or TMSUSPEND * * @throws XAException An error has occurred. Possible XAException values are XAER_RMERR, XAER_RMFAILED, XAER_NOTA, * XAER_INVAL, XAER_PROTO, or XA_RB*. */ public void end(Xid xid, int flags) throws XAException { NetAgent netAgent = conn_.netAgent_; int rc = XAResource.XA_OK; exceptionsOnXA = null; if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceEntry(this, "end", xid, flags); } if (conn_.isPhysicalConnClosed()) { connectionClosedFailure(); } NetXACallInfo callInfo = callInfoArray_[conn_.currXACallInfoOffset_]; callInfo.setReadOnlyTransactionFlag(conn_.readOnlyTransaction_); callInfo.xaFlags_ = flags; callInfo.xid_ = xid; callInfo.xaResource_ = this; callInfo.xaRetVal_ = XAResource.XA_OK; // initialize XARETVAL try { netAgent.beginWriteChainOutsideUOW(); netAgent.netConnectionRequest_.writeXaEndUnitOfWork(conn_); netAgent.flowOutsideUOW(); rc = netAgent.netConnectionReply_.readXaEndUnitOfWork(conn_); conn_.pendingEndXACallinfoOffset_ = -1; // indicate no pending end if (callInfo.xaRetVal_ != XAResource.XA_OK) { // xaRetVal has possible error, format it callInfo.xaFunction_ = XAFUNC_END; rc = xaRetValErrorAccumSQL(callInfo, rc); callInfo.xaRetVal_ = XAResource.XA_OK; // re-initialize XARETVAL } netAgent.endReadChain(); } catch (SqlException sqle) { rc = XAException.XAER_RMERR; exceptionsOnXA = org.apache.derby.client.am.Utils.accumulateSQLException (sqle, exceptionsOnXA); } finally { conn_.pendingEndXACallinfoOffset_ = -1; // indicate no pending callinfo } if (rc != XAResource.XA_OK) { // The corresponding XA connection association state // is changed by setXaStateForXAException inside the call // to throwXAException according the error code of the XAException // to be thrown. throwXAException(rc, false); }else { conn_.setXAState(Connection.XA_T0_NOT_ASSOCIATED); } } /** * Tell the resource manager to forget about a heuristically (MANUALLY) completed transaction branch. * * @param xid A global transaction identifier * * @throws XAException An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL, XAER_NOTA, * XAER_INVAL, or XAER_PROTO. */ public void forget(Xid xid) throws XAException { NetAgent netAgent = conn_.netAgent_; int rc = XAResource.XA_OK; exceptionsOnXA = null; if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceEntry(this, "forget", xid); } if (conn_.isPhysicalConnClosed()) { connectionClosedFailure(); } NetXACallInfo callInfo = callInfoArray_[conn_.currXACallInfoOffset_]; callInfo.xid_ = xid; callInfo.xaResource_ = this; callInfo.xaRetVal_ = XAResource.XA_OK; // initialize XARETVAL try { // flow the required PROTOCOL to the server netAgent.beginWriteChainOutsideUOW(); // sent the commit PROTOCOL netAgent.netConnectionRequest_.writeXaForget(netAgent.netConnection_, xid); netAgent.flowOutsideUOW(); // read the reply to the commit netAgent.netConnectionReply_.readXaForget(netAgent.netConnection_); netAgent.endReadChain(); if (callInfo.xaRetVal_ != XAResource.XA_OK) { // xaRetVal has possible error, format it callInfo.xaFunction_ = XAFUNC_FORGET; rc = xaRetValErrorAccumSQL(callInfo, rc); callInfo.xaRetVal_ = XAResource.XA_OK; // re-initialize XARETVAL } } catch (SqlException sqle) { exceptionsOnXA = org.apache.derby.client.am.Utils.accumulateSQLException (sqle, exceptionsOnXA); throwXAException(XAException.XAER_RMERR); } finally { conn_.pendingEndXACallinfoOffset_ = -1; // indicate no pending callinfo } if (rc != XAResource.XA_OK) { throwXAException(rc, false); } } /** * Obtain the current transaction timeout value set for this XAResource * instance. If XAResource.setTransactionTimeout was not use prior to * invoking this method, the return value is 0; otherwise, the value * used in the previous setTransactionTimeout call is returned. * * @return the transaction timeout value in seconds. If the returned value * is equal to Integer.MAX_VALUE it means no timeout. */ public int getTransactionTimeout() throws XAException { if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceEntry(this, "getTransactionTimeout"); } exceptionsOnXA = null; if (conn_.isPhysicalConnClosed()) { connectionClosedFailure(); } if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceExit(this, "getTransactionTimeout", timeoutSeconds); } return timeoutSeconds; } /** * Ask the resource manager to prepare for a transaction commit of the transaction specified in xid. * * @param xid A global transaction identifier * * @return A value indicating the resource manager's vote on the outcome of the transaction. The possible values * are: XA_RDONLY or XA_OK. If the resource manager wants to roll back the transaction, it should do so by * raising an appropriate XAException in the prepare method. * * @throws XAException An error has occurred. Possible exception values are: XA_RB*, XAER_RMERR, XAER_RMFAIL, * XAER_NOTA, XAER_INVAL, or XAER_PROTO. */ public int prepare(Xid xid) throws XAException { // public interface for prepare // just call prepareX with the recursion flag set to true exceptionsOnXA = null; if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceEntry(this, "prepare", xid); } if (conn_.isPhysicalConnClosed()) { connectionClosedFailure(); } /// update the XACallInfo NetAgent netAgent = conn_.netAgent_; int rc = XAResource.XA_OK; NetXACallInfo callInfo = callInfoArray_[conn_.currXACallInfoOffset_]; callInfo.xid_ = xid; callInfo.xaResource_ = this; callInfo.xaRetVal_ = XAResource.XA_OK; // initialize XARETVAL try { netAgent.beginWriteChainOutsideUOW(); // sent the prepare PROTOCOL netAgent.netConnectionRequest_.writeXaPrepare(conn_); netAgent.flowOutsideUOW(); // read the reply to the prepare rc = netAgent.netConnectionReply_.readXaPrepare(conn_); if ((callInfo.xaRetVal_ != XAResource.XA_OK) && (callInfo.xaRetVal_ != XAException.XA_RDONLY)) { // xaRetVal has possible error, format it callInfo.xaFunction_ = XAFUNC_PREPARE; rc = xaRetValErrorAccumSQL(callInfo, rc); callInfo.xaRetVal_ = XAResource.XA_OK; // re-initialize XARETVAL } netAgent.endReadChain(); } catch (SqlException sqle) { rc = XAException.XAER_RMERR; exceptionsOnXA = org.apache.derby.client.am.Utils.accumulateSQLException (sqle, exceptionsOnXA); } finally { conn_.pendingEndXACallinfoOffset_ = -1; // indicate no pending callinfo } if ((rc != XAResource.XA_OK ) && (rc != XAResource.XA_RDONLY)) { throwXAException(rc, false); } if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceExit(this, "prepare", rc); } return rc; } /** * Obtain a list of prepared transaction branches from a resource manager. The transaction manager calls this method * during recovery to obtain the list of transaction branches that are currently in prepared or heuristically * completed states. * * @param flag One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other flags are set in * flags. * * @return The resource manager returns zero or more XIDs for the transaction branches that are currently in a * prepared or heuristically completed state. If an error occurs during the operation, the resource manager * should raise the appropriate XAException. * * @throws XAException An error has occurred. Possible values are XAER_RMERR, XAER_RMFAIL, XAER_INVAL, and * XAER_PROTO. */ public Xid[] recover(int flag) throws XAException { int rc = XAResource.XA_OK; NetAgent netAgent = conn_.netAgent_; if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceEntry(this, "recover", flag); } exceptionsOnXA = null; if (conn_.isPhysicalConnClosed()) { connectionClosedFailure(); } Xid[] xidList = null; int numXid = 0; NetXACallInfo callInfo = callInfoArray_[conn_.currXACallInfoOffset_]; callInfo.xaFlags_ = flag; callInfo.xaResource_ = this; callInfo.xaRetVal_ = XAResource.XA_OK; // initialize XARETVAL try { netAgent.beginWriteChainOutsideUOW(); // sent the recover PROTOCOL netAgent.netConnectionRequest_.writeXaRecover(conn_, flag); netAgent.flowOutsideUOW(); netAgent.netConnectionReply_.readXaRecover(conn_); if (callInfo.xaRetVal_ != XAResource.XA_OK) { // xaRetVal has possible error, format it callInfo.xaFunction_ = XAFUNC_RECOVER; rc = xaRetValErrorAccumSQL(callInfo, rc); callInfo.xaRetVal_ = XAResource.XA_OK; // re-initialize XARETVAL } netAgent.endReadChain(); if (conn_.indoubtTransactions_ != null) { numXid = conn_.indoubtTransactions_.size(); xidList = new Xid[numXid]; int i = 0; nextElement = 0; for (Enumeration e = conn_.indoubtTransactions_.keys(); e.hasMoreElements(); i++) { xidList[i] = (Xid) e.nextElement(); } } } catch (SqlException sqle) { rc = XAException.XAER_RMERR; exceptionsOnXA = org.apache.derby.client.am.Utils.accumulateSQLException (sqle, exceptionsOnXA); } finally { conn_.pendingEndXACallinfoOffset_ = -1; // indicate no pending callinfo } if (rc != XAResource.XA_OK) { throwXAException(rc, false); } if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceExit(this, "recover", xidList); } return xidList; } /** * Inform the resource manager to roll back work done on behalf of a transaction branch * * @param xid A global transaction identifier * * @throws XAException An error has occurred */ public void rollback(Xid xid) throws XAException { NetAgent netAgent = conn_.netAgent_; int rc = XAResource.XA_OK; exceptionsOnXA = null; if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceEntry(this, "rollback", xid); } if (conn_.isPhysicalConnClosed()) { connectionClosedFailure(); } // update the XACallInfo NetXACallInfo callInfo = callInfoArray_[conn_.currXACallInfoOffset_]; callInfo.xid_ = xid; callInfo.xaResource_ = this; callInfo.xaRetVal_ = XAResource.XA_OK; // initialize XARETVAL try { netAgent.beginWriteChainOutsideUOW(); netAgent.netConnectionRequest_.writeXaRollback(conn_, xid); netAgent.flowOutsideUOW(); // read the reply to the rollback rc = netAgent.netConnectionReply_.readXaRollback(conn_); netAgent.endReadChain(); if (callInfo.xaRetVal_ != XAResource.XA_OK) { // xaRetVal has possible error, format it callInfo.xaFunction_ = XAFUNC_END; rc = xaRetValErrorAccumSQL(callInfo, rc); callInfo.xaRetVal_ = XAResource.XA_OK; // re-initialize XARETVAL } } catch (SqlException sqle) { rc = XAException.XAER_RMERR; exceptionsOnXA = org.apache.derby.client.am.Utils.accumulateSQLException (sqle, exceptionsOnXA); } finally { conn_.pendingEndXACallinfoOffset_ = -1; // indicate no pending callinfo } if (rc != XAResource.XA_OK) { throwXAException(rc, false); } } /** * Set the current transaction timeout value for this XAResource * instance. Once set, this timeout value is effective until * setTransactionTimeout is invoked again with a different value. To reset * the timeout value to the default value used by the resource manager, * set the value to zero. If the timeout operation is performed * successfully, the method returns true; otherwise false. If a resource * manager does not support transaction timeout value to be set * explicitly, this method returns false. * * @param seconds the transaction timeout value in seconds. * Value of 0 means the reasource manager's default value. * Value of Integer.MAX_VALUE means no timeout. * @return true if transaction timeout value is set successfully; * otherwise false. * * @exception XAException - An error has occurred. Possible exception * values are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL. */ public boolean setTransactionTimeout(int seconds) throws XAException { if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceEntry(this, "setTransactionTimeout"); } if (seconds < 0) { // throw an exception if invalid value was specified throw new XAException(XAException.XAER_INVAL); } exceptionsOnXA = null; timeoutSeconds = seconds; if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceExit(this, "setTransactionTimeout", true); } return true; } /** * Start work on behalf of a transaction branch specified in xid * * @param xid A global transaction identifier to be associated with the resource * @param flags One of TMNOFLAGS, TMJOIN, or TMRESUME * * @throws XAException An error has occurred. Possible exceptions * are XA_RB*, XAER_RMERR, XAER_RMFAIL, * XAER_DUPID, XAER_OUTSIDE, XAER_NOTA, XAER_INVAL, or XAER_PROTO. */ public synchronized void start(Xid xid, int flags) throws XAException { NetAgent netAgent = conn_.netAgent_; int rc = XAResource.XA_OK; exceptionsOnXA = null; if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceEntry(this, "start", xid, flags); } if (conn_.isPhysicalConnClosed()) { connectionClosedFailure(); } // DERBY-1025 - Flow an auto-commit if in auto-commit mode before // entering a global transaction try { if(conn_.autoCommit_) conn_.flowAutoCommit(); } catch (SqlException sqle) { rc = XAException.XAER_RMERR; exceptionsOnXA = org.apache.derby.client.am.Utils.accumulateSQLException (sqle, exceptionsOnXA); } // update the XACallInfo NetXACallInfo callInfo = callInfoArray_[conn_.currXACallInfoOffset_]; callInfo.xaFlags_ = flags; callInfo.xaInProgress_ = true; callInfo.xid_ = xid; callInfo.xaResource_ = this; callInfo.xaRetVal_ = XAResource.XA_OK; // initialize XARETVAL // check and setup the transaction timeout settings if (flags == TMNOFLAGS) { if (timeoutSeconds == Integer.MAX_VALUE) { // Disable the transaction timeout. callInfo.xaTimeoutMillis_ = 0; } else if (timeoutSeconds > 0) { // Use the timeout value specified. callInfo.xaTimeoutMillis_ = 1000*timeoutSeconds; } else if (timeoutSeconds == 0) { // The -1 value means that the timeout codepoint // will not be sent in the request and thus the server // will use the default value. callInfo.xaTimeoutMillis_ = -1; } else { // This should not ever happen due that setTransactionTimeout // does not allow a negative value throwXAException(XAException.XAER_RMERR); } } try { netAgent.beginWriteChainOutsideUOW(); netAgent.netConnectionRequest_.writeXaStartUnitOfWork(conn_); netAgent.flowOutsideUOW(); netAgent.netConnectionReply_.readXaStartUnitOfWork(conn_); if (callInfo.xaRetVal_ != XAResource.XA_OK) { // xaRetVal has possible error, format it callInfo.xaFunction_ = XAFUNC_START; rc = xaRetValErrorAccumSQL(callInfo, rc); callInfo.xaRetVal_ = XAResource.XA_OK; // re-initialize XARETVAL } // Setting this is currently required to avoid client from sending // commit for autocommit. if (rc == XAResource.XA_OK) { conn_.setXAState(Connection.XA_T1_ASSOCIATED); } } catch (SqlException sqle) { rc = XAException.XAER_RMERR; exceptionsOnXA = org.apache.derby.client.am.Utils.accumulateSQLException (sqle, exceptionsOnXA); } finally { conn_.pendingEndXACallinfoOffset_ = -1; // indicate no pending callinfo } if (rc != XAResource.XA_OK) { throwXAException(rc, false); } } protected void throwXAException(int rc) throws XAException { throwXAException(rc, rc != XAException.XAER_NOTA); } private String getXAExceptionText(int rc) { String xaExceptionText; switch (rc) { case javax.transaction.xa.XAException.XA_RBROLLBACK: xaExceptionText = "XA_RBROLLBACK"; break; case javax.transaction.xa.XAException.XA_RBCOMMFAIL: xaExceptionText = "XA_RBCOMMFAIL"; break; case javax.transaction.xa.XAException.XA_RBDEADLOCK: xaExceptionText = "XA_RBDEADLOCK"; break; case javax.transaction.xa.XAException.XA_RBINTEGRITY: xaExceptionText = "XA_RBINTEGRITY"; break; case javax.transaction.xa.XAException.XA_RBOTHER: xaExceptionText = "XA_RBOTHER"; break; case javax.transaction.xa.XAException.XA_RBPROTO: xaExceptionText = "XA_RBPROTO"; break; case javax.transaction.xa.XAException.XA_RBTIMEOUT: xaExceptionText = "XA_RBTIMEOUT"; break; case javax.transaction.xa.XAException.XA_RBTRANSIENT: xaExceptionText = "XA_RBTRANSIENT"; break; case javax.transaction.xa.XAException.XA_NOMIGRATE: xaExceptionText = "XA_NOMIGRATE"; break; case javax.transaction.xa.XAException.XA_HEURHAZ: xaExceptionText = "XA_HEURHAZ"; break; case javax.transaction.xa.XAException.XA_HEURCOM: xaExceptionText = "XA_HEURCOM"; break; case javax.transaction.xa.XAException.XA_HEURRB: xaExceptionText = "XA_HEURRB"; break; case javax.transaction.xa.XAException.XA_HEURMIX: xaExceptionText = "XA_HEURMIX"; break; case javax.transaction.xa.XAException.XA_RETRY: xaExceptionText = "XA_RETRY"; break; case javax.transaction.xa.XAException.XA_RDONLY: xaExceptionText = "XA_RDONLY"; break; case javax.transaction.xa.XAException.XAER_ASYNC: xaExceptionText = "XAER_ASYNC"; break; case javax.transaction.xa.XAException.XAER_RMERR: xaExceptionText = "XAER_RMERR"; break; case javax.transaction.xa.XAException.XAER_NOTA: xaExceptionText = "XAER_NOTA"; break; case javax.transaction.xa.XAException.XAER_INVAL: xaExceptionText = "XAER_INVAL"; break; case javax.transaction.xa.XAException.XAER_PROTO: xaExceptionText = "XAER_PROTO"; break; case javax.transaction.xa.XAException.XAER_RMFAIL: xaExceptionText = "XAER_RMFAIL"; break; case javax.transaction.xa.XAException.XAER_DUPID: xaExceptionText = "XAER_DUPID"; break; case javax.transaction.xa.XAException.XAER_OUTSIDE: xaExceptionText = "XAER_OUTSIDE"; break; case XAResource.XA_OK: xaExceptionText = "XA_OK"; break; default: xaExceptionText = "Unknown Error"; break; } return xaExceptionText; } protected void throwXAException(int rc, boolean resetFlag) throws XAException { // ~~~ String xaExceptionText; if (resetFlag) { // reset the state of the failed connection NetXACallInfo callInfo = callInfoArray_[conn_.currXACallInfoOffset_]; callInfo.xaInProgress_ = false; callInfo.xaWasSuspended = false; } xaExceptionText = getXAExceptionText(rc); // save the SqlException chain to add it to the XAException org.apache.derby.client.am.SqlException sqlExceptions = exceptionsOnXA; while (exceptionsOnXA != null) { // one or more SqlExceptions received, format them xaExceptionText = xaExceptionText + " : " + exceptionsOnXA.getMessage(); exceptionsOnXA = (org.apache.derby.client.am.SqlException) exceptionsOnXA.getNextException(); } org.apache.derby.client.am.XaException xaException = new org.apache.derby.client.am.XaException(conn_.agent_.logWriter_, sqlExceptions, xaExceptionText); xaException.errorCode = rc; setXaStateForXAException(rc); throw xaException; } /** * Reset the transaction branch association state to XA_T0_NOT_ASSOCIATED * for XAER_RM* and XA_RB* Exceptions. All other exeptions leave the state * unchanged * * @param rc // return code from XAException * @throws XAException */ private void setXaStateForXAException(int rc) { switch (rc) { // Reset to T0, not associated for XA_RB*, RM* // XAER_RMFAIL and XAER_RMERR will be fatal to the connection // but that is not dealt with here case javax.transaction.xa.XAException.XAER_RMFAIL: case javax.transaction.xa.XAException.XAER_RMERR: case javax.transaction.xa.XAException.XA_RBROLLBACK: case javax.transaction.xa.XAException.XA_RBCOMMFAIL: case javax.transaction.xa.XAException.XA_RBDEADLOCK: case javax.transaction.xa.XAException.XA_RBINTEGRITY: case javax.transaction.xa.XAException.XA_RBOTHER: case javax.transaction.xa.XAException.XA_RBPROTO: case javax.transaction.xa.XAException.XA_RBTIMEOUT: case javax.transaction.xa.XAException.XA_RBTRANSIENT: conn_.setXAState(Connection.XA_T0_NOT_ASSOCIATED); break; // No change for other XAExceptions // javax.transaction.xa.XAException.XA_NOMIGRATE //javax.transaction.xa.XAException.XA_HEURHAZ // javax.transaction.xa.XAException.XA_HEURCOM // javax.transaction.xa.XAException.XA_HEURRB // javax.transaction.xa.XAException.XA_HEURMIX // javax.transaction.xa.XAException.XA_RETRY // javax.transaction.xa.XAException.XA_RDONLY // javax.transaction.xa.XAException.XAER_ASYNC // javax.transaction.xa.XAException.XAER_NOTA // javax.transaction.xa.XAException.XAER_INVAL // javax.transaction.xa.XAException.XAER_PROTO // javax.transaction.xa.XAException.XAER_DUPID // javax.transaction.xa.XAException.XAER_OUTSIDE default: return; } } public boolean isSameRM(XAResource xares) throws XAException { boolean isSame = false; // preset that the RMs are NOT the same exceptionsOnXA = null; if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceEntry(this, "isSameRM", xares); } if (conn_.isPhysicalConnClosed()) { connectionClosedFailure(); } if (xares instanceof org.apache.derby.client.net.NetXAResource) { // both are NetXAResource so check to see if this is the same RM // remember, isSame is initialized to false NetXAResource derbyxares = (NetXAResource) xares; while (true) { if (!conn_.databaseName_.equalsIgnoreCase(derbyxares.conn_.databaseName_)) { break; // database names are not equal, not same RM } if (!conn_.netAgent_.server_.equalsIgnoreCase (derbyxares.conn_.netAgent_.server_)) { // server name strings not equal, compare IP addresses try { // 1st convert "localhost" to actual server name String server1 = this.processLocalHost(conn_.netAgent_.server_); String server2 = this.processLocalHost(derbyxares.conn_.netAgent_.server_); // now convert the server name to ip address InetAddress serverIP1 = InetAddress.getByName(server1); InetAddress serverIP2 = InetAddress.getByName(server2); if (!serverIP1.equals(serverIP2)) { break; // server IPs are not equal, not same RM } } catch (UnknownHostException ue) { break; } } if (conn_.netAgent_.port_ != derbyxares.conn_.netAgent_.port_) { break; // ports are not equal, not same RM } isSame = true; // everything the same, set RMs are the same break; } } if (conn_.agent_.loggingEnabled()) { conn_.agent_.logWriter_.traceExit (this, "isSameRM", isSame); } return isSame; } public static boolean xidsEqual(Xid xid1, Xid xid2) { // determine if the 2 xids contain the same values even if not same object // comapre the format ids if (xid1.getFormatId() != xid2.getFormatId()) { return false; // format ids are not the same } // compare the global transaction ids int xid1Length = xid1.getGlobalTransactionId().length; if (xid1Length != xid2.getGlobalTransactionId().length) { return false; // length of the global trans ids are not the same } byte[] xid1Bytes = xid1.getGlobalTransactionId(); byte[] xid2Bytes = xid2.getGlobalTransactionId(); int i; for (i = 0; i < xid1Length; ++i) { // check all bytes are the same if (xid1Bytes[i] != xid2Bytes[i]) { return false; // bytes in the global trans ids are not the same } } // compare the branch qualifiers xid1Length = xid1.getBranchQualifier().length; if (xid1Length != xid2.getBranchQualifier().length) { return false; // length of the global trans ids are not the same } xid1Bytes = xid1.getBranchQualifier(); xid2Bytes = xid2.getBranchQualifier(); for (i = 0; i < xid1Length; ++i) { // check all bytes are the same if (xid1Bytes[i] != xid2Bytes[i]) { return false; // bytes in the global trans ids are not the same } } return true; // all of the fields are the same, xid1 == xid2 } public List getSpecialRegisters() { return specialRegisters_; } public void addSpecialRegisters(String s) { if (s.substring(0, 1).equals("@")) { // SET statement is coming from Client if (specialRegisters_.remove(s.substring(1))) { specialRegisters_.remove(s); specialRegisters_.add(s.substring(1)); } else { specialRegisters_.remove(s); specialRegisters_.add(s); } } else { // SET statement is coming from Server specialRegisters_.remove(s); specialRegisters_.add(s); } } private void connectionClosedFailure() throws XAException { // throw an XAException XAER_RMFAIL, with a chained SqlException - closed exceptionsOnXA = org.apache.derby.client.am.Utils.accumulateSQLException (new SqlException(null, new ClientMessageId(SQLState.NO_CURRENT_CONNECTION)), exceptionsOnXA); throwXAException(javax.transaction.xa.XAException.XAER_RMFAIL); } private String getXAFuncStr(int xaFunc) { switch (xaFunc) { case XAFUNC_COMMIT: return XAFUNCSTR_COMMIT; case XAFUNC_END: return XAFUNCSTR_END; case XAFUNC_FORGET: return XAFUNCSTR_FORGET; case XAFUNC_PREPARE: return XAFUNCSTR_PREPARE; case XAFUNC_RECOVER: return XAFUNCSTR_RECOVER; case XAFUNC_ROLLBACK: return XAFUNCSTR_ROLLBACK; case XAFUNC_START: return XAFUNCSTR_START; } return XAFUNCSTR_NONE; } protected int xaRetValErrorAccumSQL(NetXACallInfo callInfo, int currentRC) { // xaRetVal_ is set by the server to be one of the // standard constants from XAException. int rc = callInfo.xaRetVal_; if (rc != XAResource.XA_OK) { // error was detected // create an SqlException to report this error within SqlException accumSql = new SqlException(conn_.netAgent_.logWriter_, new ClientMessageId(SQLState.NET_XARETVAL_ERROR), getXAFuncStr(callInfo.xaFunction_), getXAExceptionText(rc), org.apache.derby.client.am.SqlCode.queuedXAError); exceptionsOnXA = org.apache.derby.client.am.Utils.accumulateSQLException (accumSql, exceptionsOnXA); if (currentRC != XAResource.XA_OK) { // the rc passed into this function had an error also, prioritize error if (currentRC < 0) { // rc passed in was a major error use it instead of current error return currentRC; } } } return rc; } private String processLocalHost(String serverName) { if (serverName.equalsIgnoreCase("localhost")) { // this is a localhost, find hostname try { InetAddress localhostNameIA = InetAddress.getLocalHost(); String localhostName = localhostNameIA.getHostName(); return localhostName; } catch (SecurityException se) { return serverName; } catch (UnknownHostException ue) { return serverName; } } // not "localhost", return original server name return serverName; } protected void removeXaresFromSameRMchain() { // check all NetXAResources on the same RM for the NetXAResource to remove try { this.ignoreMe_ = true; // use the ignoreMe_ flag to indicate the // XAResource to remove NetXAResource prevXAResource = null; NetXAResource currXAResource; synchronized (xaResourceSameRMGroup_) { // make sure no one changes this vector list currXAResource = (NetXAResource) xaResourceSameRMGroup_.elementAt(sameRMGroupIndex_); while (currXAResource != null) { // is this the XAResource to remove? if (currXAResource.ignoreMe_) { // this NetXAResource is the one to remove if (prevXAResource != null) { // this XAResource is not first in chain, just move next to prev prevXAResource.nextSameRM_ = currXAResource.nextSameRM_; } else { // this XAResource is first in chain, just move next to root xaResourceSameRMGroup_.set(sameRMGroupIndex_, currXAResource.nextSameRM_); } return; } // this is not the NetXAResource to remove, try the next one prevXAResource = currXAResource; currXAResource = currXAResource.nextSameRM_; } } } finally { this.ignoreMe_ = false; } } public void initForReuse() { // add this new XAResource to the list of other XAResources for the Same RM // first find out if there are any other XAResources for the same RM // then check to make sure it is not already in the chain synchronized (xaResourceSameRMGroup_) { // make sure no one changes this vector list int groupCount = xaResourceSameRMGroup_.size(); int index = 0; int firstFreeElement = -1; NetXAResource xaResourceGroup = null; for (; index < groupCount; ++index) { // check if this group is the same RM xaResourceGroup = (NetXAResource) xaResourceSameRMGroup_.elementAt(index); if (xaResourceGroup == null) { // this is a free element, save its index if first found if (firstFreeElement == -1) { // first free element, save index firstFreeElement = index; } continue; // go to next element } try { if (xaResourceGroup.isSameRM(this)) { // it is the same RM add this XAResource to the chain if not there NetXAResource nextXares = (NetXAResource) xaResourceSameRMGroup_.elementAt(sameRMGroupIndex_); while (nextXares != null) { // is this NetXAResource the one we are trying to add? if (nextXares.equals(this)) { // the XAResource to be added already is in chain, don't add break; } // Xid was not on that NetXAResource, try the next one nextXares = nextXares.nextSameRM_; } if (nextXares == null) { // XAResource to be added is not in the chain already, add it // add it at the head of the chain sameRMGroupIndex_ = index; this.nextSameRM_ = xaResourceGroup.nextSameRM_; xaResourceGroup.nextSameRM_ = this; } return; // done } } catch (XAException xae) { } } // no other same RM was found, add this as first of new group if (firstFreeElement == -1) { // no free element found, add new element to end xaResourceSameRMGroup_.add(this); sameRMGroupIndex_ = groupCount; } else { // use first free element found xaResourceSameRMGroup_.setElementAt(this, firstFreeElement); sameRMGroupIndex_ = firstFreeElement; } } } }

The table below shows all metrics for NetXAResource.java.

MetricValueDescription
BLOCKS143.00Number of blocks
BLOCK_COMMENT20.00Number of block comment lines
COMMENTS223.00Comment lines
COMMENT_DENSITY 0.35Comment density
COMPARISONS79.00Number of comparison operators
CYCLOMATIC162.00Cyclomatic complexity
DECL_COMMENTS16.00Comments in declarations
DOC_COMMENT125.00Number of javadoc comment lines
ELOC635.00Effective lines of code
EXEC_COMMENTS47.00Comments in executable code
EXITS73.00Procedure exits
FUNCTIONS24.00Number of function declarations
HALSTEAD_DIFFICULTY129.91Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY93.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 2.00JAVA0007 Should not declare public field
JAVA0008 1.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 1.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 1.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 1.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 5.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 1.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 1.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 1.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 0.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 0.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 1.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 1.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA011624.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 9.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 1.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 1.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 3.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 1.00JAVA0143 Synchronized method
JAVA0144 2.00JAVA0144 Line exceeds maximum M characters
JAVA014517.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 4.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 1.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 1.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1065.00Number of lines in the source file
LINE_COMMENT78.00Number of line comments
LOC755.00Lines of code
LOGICAL_LINES422.00Number of statements
LOOPS 9.00Number of loops
NEST_DEPTH 7.00Maximum nesting depth
OPERANDS1764.00Number of operands
OPERATORS3052.00Number of operators
PARAMS29.00Number of formal parameter declarations
PROGRAM_LENGTH4816.00Halstead program length
PROGRAM_VOCAB444.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS64.00Number of return points from functions
SIZE45652.00Size of the file in bytes
UNIQUE_OPERANDS387.00Number of unique operands
UNIQUE_OPERATORS57.00Number of unique operators
WHITESPACE87.00Number of whitespace lines