Comments (5)
Yikes. A bit of a design flaw. Thanks @nicoweidner for pointing this out. This is probably a root cause of a few issues.
The change you proposed is very logical, but as you point out it is potentially breaking since the semantics.
I wonder if there may be another interface option that would preserve the existing semantics.
I was thinking of using the strict
flag to force errors is the ID already exists, however, currently it can only be set after the ModelObject
is created.
from spdx-java-library.
One thought is to add a new constructor with different semantics and deprecate the old one. We could add a strict
parameter, for example. It would require, however, updating a lot of code.
The idea behind the strict
parameter is, if it is set to true then the call will fail if the ID already exists. Otherwise, it would behave the way it does today. This is similar to how the library treats other checks on parameter validity.
I have mixed feeling about whether the strict
approach is a good one. @nicoweidner - let me know what you think.
from spdx-java-library.
@nicoweidner I came up with another (partial) solution we could implement with low risk.
If create
is true and there is another ModelObject
in the store with the same ID, check to see if the type of the ModelObject
in the store is the same as type type of the newly created ModelObject
. We could fail if they are different types.
This would preserve the semantics of re-using an ModelObject
even if create
is true. It would prevent the non-symentric equals behavior mentioned in PR 112 comments.
I'm pretty comfortable no one would intentionally create a ModelObject
with a different type expecting it to reuse the properties of a previous type.
The only case this doesn't cover is if someone accidentally creates 2 ModelObject
s of the same type with the same ID.
from spdx-java-library.
@goneall Given the current situation, I prefer your latest suggestion of failing when someone tries to create an object with the same id, but of different type. That should prevent all the bad scenarios, and is little effort.
from spdx-java-library.
Fixed (mostly) with PR #121
from spdx-java-library.
Related Issues (20)
- Regression: inconsistent results between LicenseCompareHelper.isTextStandardLicense(), LicenseCompareHelper.isStandardLicenseWithinText(), and LicenseCompareHelper.matchingStandardLicenseIdsWithinText() HOT 22
- LicenseCompareHelper: Apache-1.0 & 1.1 license texts published by Apache not recognised HOT 6
- Long strings when verifying an SPDX document with deeply nested relationships
- Relationship why not have 'spdxElementId' field? HOT 2
- Update POM file to use release plugin HOT 1
- Enhancement: caching version of org.spdx.storage.listedlicense.SpdxListedLicenseWebStore and associated classes HOT 27
- tools-java should issue an error for absolute FileName HOT 5
- Need to update optional fields handling for cases with filesAnalyzed=true HOT 2
- Exceptions.json details URL should be a full URL HOT 1
- Do we have a release schedule? HOT 4
- Performance enhancement: only download and parse license & exception JSON files once
- Exceptions aren't always passed on, making troubleshooting difficult
- Update CI to flag any new quality issues
- LicenseCompareHelper: EPL-2.0 license text published by Eclipse Foundation not recognised HOT 3
- LicenseCompareHelper: BSD-2-Clause license text not recognised HOT 2
- In need of a canonical way to add license texts for licenseRefs / Maybe bugged? HOT 4
- LicenseCompareHelper: GPL-2.0 license text not recognised HOT 2
- Question HOT 2
- Refactor nonOptionalTextToPatterns HOT 2
- Verify error when license exceptions are used in an expression in LicenseConcluded but not in LicenseInfoInFile HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spdx-java-library.