Skip to content

Commit 5448bfc

Browse files
adaussyAxelRICHARD
authored andcommitted
[2032] NPE when exporting LiteralString
Bug: #2032 Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
1 parent b68d8bf commit 5448bfc

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ For example `ViewUsage` elements are no longer rendered in _parts_ compartments.
7575
- https://github.com/eclipse-syson/syson/issues/1998[#1998] [metamodel] Missing implicit TypeFeaturing.
7676
- https://github.com/eclipse-syson/syson/issues/2023[#2023] [diagrans] On diagrams, `ConnectionDefinition` graphical nodes are now correctly labelled as `«connection def»`.
7777
- https://github.com/eclipse-syson/syson/issues/2034[#2034] [import] Fix textual import to be able to annotate `Relationships`.
78+
- https://github.com/eclipse-syson/syson/issues/2032[#2032] [export] Fix NPE when exporting `LiteralString`.
7879

7980
=== Improvements
8081

backend/application/syson-application/src/test/java/org/eclipse/syson/sysml/textual/SysMLElementSerializerTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,9 @@ public void literalString() {
12571257
literalStr.setValue("value");
12581258

12591259
this.assertTextualFormEquals("\"value\"", literalStr);
1260+
1261+
literalStr.setValue(null);
1262+
this.assertTextualFormEquals("\"\"", literalStr);
12601263
}
12611264

12621265
@Test

backend/metamodel/syson-sysml-metamodel/src/main/java/org/eclipse/syson/sysml/textual/SysMLElementSerializer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,9 @@ private String toPreciseReal(double value) {
631631
public String caseLiteralString(LiteralString literal) {
632632
Appender builder = this.newAppender();
633633
builder.append("\"");
634-
builder.append(literal.getValue().replace("\"", "\\\""));
634+
if (literal.getValue() != null) {
635+
builder.append(literal.getValue().replace("\"", "\\\""));
636+
}
635637
builder.append("\"");
636638
return builder.toString();
637639
}

doc/content/modules/user-manual/pages/release-notes/2026.3.0.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ package Test {
8484
}
8585
```
8686

87+
** Fix a textual export problem while exporting `LiteralString` with no value.
88+
8789
* In _Explorer_ view:
8890

8991
** Fix an issue where creating a new model using the _Create a new model_ action in the _Explorer_ view was not adding the ".sysml" extension to the model name.

0 commit comments

Comments
 (0)