| Author |
Unreachable code question
|
Melinda Savoy
Ranch Hand
Joined: Jun 21, 2005
Posts: 375
|
|
In the following code, where BOLDED, I do not understand why this is UNREACHABLE CODE: public class EndTransactionSOAPImpl implements org.tempuri.EndTransaction_PortType{ public org.texashealth.www.SCM.DataTier.GenericResponse.GenericResponse endTransaction(org.texashealth.www.SCM.DataTier.ETRequest.EndTransactionRequest endTransaction ) throws java.rmi.RemoteException { // Create the "GenericResponse" and "Header" objects. GenericResponse response = new GenericResponse(); Header responseheader = new Header(); // Stuff the responseheader with the hardcoded VERSION and STATUS. responseheader.setVersion(BigInteger.valueOf(1)); responseheader.setStatus(Status.fromString("OK")); // Stuff the "response" object variable by passing // in the header object. response.setHeader(responseheader); // Delete or keep the transaction by verifying the transaction exists in the hash table. Transaction transaction = new Transaction(); if (endTransaction.getHeader().getVersion().intValue() != 1) responseheader.setStatus(Status.fromString("VersionNotSupported")); return response; int transID = endTransaction.getTransactionID().intValue(); if (Transaction.get(transID) == null) responseheader.setStatus(Status.fromString("InvalidTransactionID")); return response; Transaction.remove(endTransaction.getTransactionID().intValue()); responseheader.setStatus(Status.fromString("OK")); return response; } } Any help or direction would be appreciated. Thanks.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
That's what's stopping you. Its always a good idea to use curly brackets {} to demarcate blocks of logic, such as if conditions. Without the brackets, your if() only includes the one line after it in its conditional block. [ July 08, 2005: Message edited by: Paul Sturrock ]
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Shrinivas Mujumdar
Ranch Hand
Joined: Aug 27, 2004
Posts: 328
|
|
Hello See the line above bold variable you are saying return statement so how you can expect the control will go to the next line. The if statement you have written must have a {}block after that & return should be inside that block. Shrinivas
|
 |
Melinda Savoy
Ranch Hand
Joined: Jun 21, 2005
Posts: 375
|
|
The braces {} were indeed missing. Stupid mistake, sorry about that. Thanks for the responses. Sure appreciate the time. Regards.
|
 |
 |
|
|
subject: Unreachable code question
|
|
|