[MGNLPN-223] Some traits might be session scoped Created: 08/Jul/15  Updated: 01/Nov/17  Resolved: 26/Jul/17

Status: Closed
Project: Magnolia Personalization
Component/s: Integration
Affects Version/s: None
Fix Version/s: 1.4.6

Type: Story Priority: Neutral
Reporter: Roman Kovařík Assignee: Roman Kovařík
Resolution: Fixed Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
dependency
depends upon MGNLPN-380 VisitorDetectorFilter unable to creat... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Documentation update required:
Yes
Date of First Response:
Sprint: Kromeriz 96, Kromeriz 99, Kromeriz 106
Story Points: 13

 Description   

A trait resolving per request is not necessary for most of the traits and may be too slow, especially if we need to connect to external services.



 Comments   
Comment by Roman Kovařík [ 31/May/17 ]

Reopened, traitClass might be null while creating a new trait:

java.lang.NullPointerException
	info.magnolia.personalization.trait.storage.StorageAwareTraitCollector.lambda$getTraitDefinition$0(StorageAwareTraitCollector.java:61)
	java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
	java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1351)
	java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
	java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
	java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
	java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
	java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
	info.magnolia.personalization.trait.storage.StorageAwareTraitCollector.getTraitDefinition(StorageAwareTraitCollector.java:62)

Also, this code should throw an exception or at least log if definition is null (if it would break when creating a new trait):

public <T> void addTraits(Class<T> c, T o) {
        final TraitDefinition traitDefinition = getTraitDefinition(c);
        if (traitDefinition != null) {
            getTraitStorage(traitDefinition.getTraitStorageClass()).addTrait(traitDefinition, o);
        }
    }
Comment by Roman Kovařík [ 29/Jun/17 ]

Detected session scope traits should not be valid for preview.

ajuran Could you add steps to reproduce?

Decision: Revert from 1.4.5.

Comment by Antonín Juran [ 29/Jun/17 ]

How to reproduce:

  1. add variant to a page
  2. choose audience and select segment America for the variant
  3. add Text and Image component to the variant page and fill headline field of the component with “America”
  4. preview as “Anonymous” visitor the page - you see the headline of the component “America” which should be visible only for users from America region not for Anonymous user
Generated at Mon Feb 12 06:35:31 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.