Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.netgrif</groupId>
<artifactId>application-engine-parent</artifactId>
<version>7.0.0-RC10.1</version>
<version>7.0.0-RC10.2</version>
</parent>

<artifactId>application-engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ public void evictAllCaches() {
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetByIdentifier()), cacheProperties.getPetriNetByIdentifier()).clear();
}

@Override
public void evictCache(String id, String identifier, String version) {
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetById()), cacheProperties.getPetriNetById()).evict(id);
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetDefault()), cacheProperties.getPetriNetDefault()).evict(identifier);
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetLatest()), cacheProperties.getPetriNetLatest()).evict(identifier);
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetCache()), cacheProperties.getPetriNetCache()).evict(new ObjectId(id));
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetByIdentifier()), cacheProperties.getPetriNetByIdentifier()).evict(identifier + version);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

public void evictCache(PetriNet net) {
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetById()), cacheProperties.getPetriNetById()).evict(net.getStringId());
requireNonNull(cacheManager.getCache(cacheProperties.getPetriNetDefault()), cacheProperties.getPetriNetDefault()).evict(net.getIdentifier());
Expand All @@ -150,7 +159,7 @@ public void evictCache(PetriNet net) {
* Get read only Petri net.
*/
@Override
@Cacheable(value = "petriNetCache")
@Cacheable(value = "petriNetCache", unless = "#result == null")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

unless = "#result == null" is a no-op here and does not implement the PR objective

At Line 153 and Line 304, both methods throw on not-found instead of returning null, so the unless condition is never hit and caching behavior is unchanged. This likely leaves NAE-2400 unresolved in this class.

Based on learnings: In this repository, petriNetService.get() does not return null when a net is missing; it fails via exception.

Also applies to: 304-304

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@application-engine/src/main/java/com/netgrif/application/engine/petrinet/service/PetriNetService.java`
at line 153, The `@Cacheable` unless="#result == null" is ineffective because the
two PetriNetService methods currently throw when a net is missing instead of
returning null; update the two cached methods in PetriNetService (the two
methods currently annotated with `@Cacheable`) to catch the "not found" exception
they throw (e.g., ResourceNotFoundException/NoSuchElementException used in this
service) and return null instead so the unless condition can take effect and
missing nets are not cached; ensure you only convert the missing-resource path
to return null and preserve throwing for other error cases.

public PetriNet get(ObjectId petriNetId) {
Optional<PetriNet> optional = repository.findById(petriNetId.toString());
if (optional.isEmpty()) {
Expand Down Expand Up @@ -301,7 +310,7 @@ protected final Optional<PetriNet> doSaveInternal(PetriNet petriNet) {
}

@Override
@Cacheable(value = "petriNetById")
@Cacheable(value = "petriNetById", unless = "#result == null")
public PetriNet getPetriNet(String id) {
Optional<PetriNet> net = repository.findById(id);
if (net.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ ImportPetriNetEventOutcome importPetriNet(ImportPetriNetParams importPetriNetPar
*/
void evictAllCaches();

void evictCache(String id, String identifier, String version);

/**
* Evicts the cache for the given {@link PetriNet}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public void cachePetriNetFunctions(PetriNet petriNet) {
return;
}

log.info("Caching functions for PetriNet id={}", petriNet.getIdentifier());

List<CachedFunction> functions = petriNet.getFunctions(FunctionScope.GLOBAL).stream()
.map(function -> CachedFunction.build(shell, function))
.collect(Collectors.toList());
Expand All @@ -66,6 +68,7 @@ public void cachePetriNetFunctions(PetriNet petriNet) {
} else {
globalFunctionsCache.evictIfPresent(petriNet.getIdentifier());
}
log.info("Finished caching functions for PetriNet id={}", petriNet.getIdentifier());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion nae-object-library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.netgrif</groupId>
<artifactId>application-engine-parent</artifactId>
<version>7.0.0-RC10.1</version>
<version>7.0.0-RC10.2</version>
</parent>

<artifactId>nae-object-library</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nae-spring-core-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.netgrif</groupId>
<artifactId>application-engine-parent</artifactId>
<version>7.0.0-RC10.1</version>
<version>7.0.0-RC10.2</version>
</parent>

<artifactId>nae-spring-core-adapter</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nae-user-ce/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.netgrif</groupId>
<artifactId>application-engine-parent</artifactId>
<version>7.0.0-RC10.1</version>
<version>7.0.0-RC10.2</version>
</parent>

<artifactId>nae-user-ce</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nae-user-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.netgrif</groupId>
<artifactId>application-engine-parent</artifactId>
<version>7.0.0-RC10.1</version>
<version>7.0.0-RC10.2</version>
</parent>

<artifactId>nae-user-common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.netgrif</groupId>
<artifactId>application-engine-parent</artifactId>
<version>7.0.0-RC10.1</version>
<version>7.0.0-RC10.2</version>
<packaging>pom</packaging>

<name>NETGRIF Application Engine parent</name>
Expand Down
Loading