Skip to content

Commit

Permalink
Fix #1712 - creating a connection with null name produced a NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Jul 28, 2019
1 parent cb598e4 commit 9df2476
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Connection extends ModelElement {
@Accessors RelationType relationType

new(String name, Shape source, Shape target, RelationType relationType) {
this.name = name.split("\\.").last
this.name = if (name === null) "" else name.split("\\.").last
this.identifier = source?.toString + this.name + target.toString
this.relationType = relationType
reconnect(source, target, relationType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.uqbar.project.wollok.scoping
import com.google.common.base.Predicate
import com.google.inject.Inject
import com.google.inject.Singleton
import java.util.Set
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.EClass
import org.eclipse.emf.ecore.resource.Resource
Expand Down Expand Up @@ -90,10 +91,13 @@ class WollokGlobalScopeProvider extends DefaultGlobalScopeProvider {
objectsFromLocalImport(context, imports, objectsFromManifests)
}

def synchronized objectsFromLocalImport(Resource context, Iterable<String> importsEntry,
def objectsFromLocalImport(Resource context, Iterable<String> importsEntry,
Iterable<IEObjectDescription> objectsFromManifests) {
val imports = (importsEntry.map[#[it] + localScopeProvider.allRelativeImports(it, context.implicitPackage)].
flatten).toSet
var Set<String> imports
synchronized (this) {
imports = (importsEntry.map[#[it] + localScopeProvider.allRelativeImports(it, context.implicitPackage)].
flatten).toSet
}

val importedObjects = imports.filter [
it !== null && !objectsFromManifests.exists[o|o.matchesImport(it)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ class StringUtils {
return String.format("%1$-" + n + "s", s);
}

def static String truncate(String s, int max) {
if(s.length < max) return s
s.substring(0, max) + "..."
def static String truncate(String value, int max) {
if (value === null) return ""
if (value.length < max) return value
value.substring(0, max) + "..."
}

/**
Expand Down

0 comments on commit 9df2476

Please sign in to comment.