Skip to content

Commit

Permalink
Corrects two uncaught NPE
Browse files Browse the repository at this point in the history
Direct push (no PR) as these changes are really minor and mostly fixing odd NPEs
  • Loading branch information
AlexisDrogoul committed Oct 30, 2024
1 parent 469f87e commit da0618a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gama.core/src/gama/core/util/file/GamaGridFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ void read(final IScope scope, final boolean readAll, final boolean createGeometr
records.fill(i, bands);
rect.setAttribute("grid_value", bands.get(0));
rect.setAttribute("bands", bands);
((IList) getBuffer()).add(rect);
getBuffer().add(rect);
}
}
}
Expand Down Expand Up @@ -822,7 +822,7 @@ protected SimpleFeatureCollection getFeatureCollection(final IScope scope) {

@Override
public double getNoData(final IScope scope) {
return noData.doubleValue();
return noData == null ? IField.NO_NO_DATA : noData.doubleValue();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import gama.core.util.GamaMapFactory;
import gama.core.util.IMap;
import gama.dev.DEBUG;
import gaml.compiler.gaml.resource.GamlResource;
import gaml.compiler.gaml.resource.ImportedResources;
import gaml.compiler.gaml.ExperimentFileStructure;
import gaml.compiler.gaml.GamlPackage;
import gaml.compiler.gaml.Import;
import gaml.compiler.gaml.Model;
import gaml.compiler.gaml.impl.ModelImpl;
import gaml.compiler.gaml.resource.GamlResource;
import gaml.compiler.gaml.resource.ImportedResources;

/**
* The Class GamlResourceIndexer.
Expand Down Expand Up @@ -113,7 +113,8 @@ private static Map<URI, String> getImportsAsAbsoluteURIS(final URI baseURI, fina
static private EObject findImport(final EObject contents, final URI baseURI, final URI uri) {
if (contents instanceof ExperimentFileStructure expe) {
String u = expe.getExp().getImportURI();
if (u.contains(URI.decode(uri.lastSegment())) || uri.equals(baseURI) && u.isEmpty()) return contents;
String lastSegment = URI.decode(uri.lastSegment());
if (lastSegment != null && u.contains(lastSegment) || uri.equals(baseURI) && u.isEmpty()) return contents;
} else if (contents instanceof Model model) {
for (final Import imp : model.getImports()) {
if (imp.getImportURI().contains(URI.decode(uri.lastSegment()))) return imp;
Expand Down

0 comments on commit da0618a

Please sign in to comment.