Thank you Matthew for the quick response. Sorry that my question was not 
very clear.  The document you shared is helpful.
 Let me rephrase my question

The enum classes generated out of protoc version (very old), that we are 
using currently,  do not throw any exception. So we have lot of usages of 
set<FieldNameXX> throughout the project for multiple classes. Now after 
changing to latest protoc generator, all these usages can throw exception 
runtime and crash the application.  Finding direct usages of these classes 
are very difficult and given it is runtime exception, we can't be 100% sure 
we removed all those usages. 

1) So I am looking for idea to tackle this situation. 
2) How to make sure, in future, no one accidentally uses this 
set<FieldNameXX> or Enum.getNumber()methods [I am talking about huge team 
with lot of engineers]

On Tuesday, May 9, 2023 at 12:23:02 PM UTC+9 Matthew Fowles Kulukundis 
wrote:

> Karthi~
>
> I am not entirely sure I understand your question, but I suspect the note 
> on Java's enum behavior at 
> https://protobuf.dev/programming-guides/enum/#java might help.  If you 
> use the `get<FieldName>Value` and `set<FieldName>Value` methods they will 
> not throw exceptions.
>
> Cheers,
> Matt
>
> On Mon, May 8, 2023 at 11:17 PM Karthi Ayappan <[email protected]> 
> wrote:
>
>> Hi,
>>
>> Context: I am trying to migrate very old protoc generated models library 
>> (protobuf-lite which is no longer available) to protobuf-javalite. Once I 
>> switched to latest protoc version, the generated enum throws 
>> IllegalStateException on getNumber via setEnum methods. We have huge number 
>> of such usage in our very big project. 
>>
>> Question: 
>> 1. How to gracefully avoid it without making sweeping changes in the 
>> code. I am talking about hundreds of such new enum classes and even more 
>> number of usages of those enums in multiple modules in our code. Specially 
>> I want to avoid this exception with minimal change.
>> 2. Could someone point me to doc or give me context on why we have this 
>> unChecked exception (escpecially while referring from kotlin code). 
>>
>> Any idea to fix this is very welcome. Thanks in advance. 
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Protocol Buffers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/protobuf/54542179-cb17-43c7-b2cb-67268819c05en%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/protobuf/54542179-cb17-43c7-b2cb-67268819c05en%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/8bd65fe5-f1b3-4b08-a606-c0bf5238a38cn%40googlegroups.com.

Reply via email to