• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unreachable code question

 
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The braces {} were indeed missing. Stupid mistake, sorry about that.

Thanks for the responses. Sure appreciate the time.

Regards.
 
reply
    Bookmark Topic Watch Topic
  • New Topic