Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Non-serializable service references

Avatar

Avatar
Validate 1
Level 1
Williamvdev
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Give Back
View profile

Avatar
Validate 1
Level 1
Williamvdev
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Give Back
View profile
Williamvdev
Level 1

23-03-2021

Re-posting this question in the Adobe Experience Manager section

Hi, we recently started using the Cloud Manager pipelines to run analysis on our code and one of the critical code smells that keep popping up is the following:

 

IssueTypeSeverityEffortRuleTagsDocumentation
Make "cryptoSupport" transient or serializable.Code SmellCritical30minsquid:S1948cwe,serializationhttps://www.adobe.com/go/aem_cmcq_s1948_en

 

In this case "cryptoSupport" refers to an injected service that implements the com.adobe.granite.crypto.CryptoSupport interface.

 

@reference
private CryptoSupport cryptoSupport;

 

My question is: Since we can't make CryptoSupport serializable, is it safe to declare the field as transient? Is there any danger of our servlet (that contains the above service reference) being flushed to disk at some point and failing to restore the service reference later?

 

Thank you,

William.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

551 likes

Total Posts

663 posts

Correct Reply

191 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

551 likes

Total Posts

663 posts

Correct Reply

191 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile
asutosh_jena
Level 10

23-03-2021

Hi @Williamvdev 

You should be able to make it as transient and it should not have any issue as they will not be part of persistent state.

@Reference
private transient CryptoSupport cryptoSupport;

Thanks! 

Answers (0)