UwF: Unwritten field (UWF_UNWRITTEN_FIELD) Spotbug

When i try to instantiate the StockQuoteService class using the getService() method in StoockQuotesServiceFactory i get this Spotbug.

Am i doing the instantiation wrong? Please Help!!

Yes you’re in java their is no way to instantiate interface. And according to your question you’re doing wrong. In StockQuotesServiceFactory you need not to use getService() method. Because you have to give implementation to getService() method in StockQuotesServiceFactory.

1 Like

Hi @Aanand,

The problem here looks to be the fact that you are trying to instantiate an interface.

Instead of that, you need to implement the getService in StoockQuotesServiceFactory by returning the appropriate service type depending on the provider string passed. The return type will be StockQuoteService only, since you can return service of two different types.

Let me know if face any issues in implementing it!

1 Like

@Aanand Is your issue resolved or not?

Ohhhh! Will try it out and let you know in a bit. Thanks a lot!

Still trying to figure things out sir. Would greatly appreciate if there was a session cover this module!

Hey @shoryajain @akashchhetri This issue occurs when i have to do the following TODO :
// Implement the method in such a way that it will return new Instance of PortfolioManager

// using RestTemplate and provider name.

// As a first step, Create appropriate instance of StoockQuoteService using

// StockQuoteServiceFactory and then use the same instance of StockQuoteService to create the

// instance of PortfolioManager.

// Mark the earlier constructor of PortfolioManager as @Deprecated.

Thanks for the feedback, we will think about it :slight_smile:
@Aanand Can you give me confirmation that your issue is resolved?

No sir, it isnt… I am stuck in the portfoliomanagerFactory where i have to return an instance of StockQuoteService using The respective factory. it throws NullException

You can create a method which gives an object in return in one factory and then use that method to create object in another factory like Factory.INSTANCE.methodName(parameter-1, parameter-2)

Please let me know if it was helpful or not.

Thank you so much sir! It worked! Is this because of enum?

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, please feel free to create a new topic and post this question as a reference link in the description of the new topic.

1 Like