This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 48e238f9ba Make a GeoTIFF writer test tolerance to the case where the
EPSG database is absent. Better error messages.
48e238f9ba is described below
commit 48e238f9baa71004eb596f3e490d980f3e88ba6a
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Fri Nov 24 10:44:51 2023 +0100
Make a GeoTIFF writer test tolerance to the case where the EPSG database is
absent.
Better error messages.
---
.../org/apache/sis/filter/internal/FunctionNames.java | 2 +-
.../org/apache/sis/storage/landsat/LandsatStore.java | 2 +-
.../org/apache/sis/storage/landsat/MetadataReader.java | 2 +-
.../sis/storage/geotiff/MultiResolutionImage.java | 4 ++--
.../main/org/apache/sis/storage/geotiff/Writer.java | 2 +-
.../org/apache/sis/storage/geotiff/WriterTest.java | 9 +++++++--
.../main/org/apache/sis/system/Modules.java | 5 -----
.../main/org/apache/sis/util/Classes.java | 18 +++++++++++++++---
.../main/org/apache/sis/util/logging/Logging.java | 17 +++--------------
9 files changed, 31 insertions(+), 30 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/FunctionNames.java
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/FunctionNames.java
index 4cacfb13fe..fe8d30f6fe 100644
---
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/FunctionNames.java
+++
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/internal/FunctionNames.java
@@ -22,7 +22,7 @@ import org.apache.sis.filter.sqlmm.SQLMM;
/**
* Names of some expressions used in Apache SIS.
- * This class defines only the names that need to be references from at least
two different classes.
+ * This class defines only the names that need to be referenced from at least
two different classes.
*
* @author Martin Desruisseaux (Geomatys)
*/
diff --git
a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
index fa0ccaa9b6..74ab128a7d 100644
---
a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
+++
b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
@@ -235,7 +235,7 @@ public class LandsatStore extends DataStore implements
Aggregate {
} catch (IOException e) {
throw new DataStoreException(e);
} catch (FactoryException e) {
- throw new DataStoreReferencingException(e);
+ throw new DataStoreReferencingException(e.getMessage(), e);
}
final BandGroup[] bands = BandGroup.group(listeners, resources, count);
for (final BandGroup c : bands) {
diff --git
a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java
b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java
index 11d10ebb93..14a8b18580 100644
---
a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java
+++
b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java
@@ -680,7 +680,7 @@ final class MetadataReader extends MetadataBuilder {
utmZone = -1;
} catch (NoSuchIdentifierException e) {
// Should never happen with Apache SIS implementation of
MathTransformFactory.
- throw new DataStoreReferencingException(e);
+ throw new DataStoreReferencingException(e.getMessage(), e);
}
break;
}
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/MultiResolutionImage.java
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/MultiResolutionImage.java
index b2b73a874e..1ffe184673 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/MultiResolutionImage.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/MultiResolutionImage.java
@@ -182,7 +182,7 @@ final class MultiResolutionImage extends
GridResourceWrapper implements Resource
}
resolutions[level] = resolution;
} catch (TransformException e) {
- throw new DataStoreReferencingException(e);
+ throw new DataStoreReferencingException(e.getMessage(), e);
} catch (IOException e) {
throw levels[level].reader.store.errorIO(e);
}
@@ -238,7 +238,7 @@ final class MultiResolutionImage extends
GridResourceWrapper implements Resource
}
}
} catch (FactoryException | TransformException e) {
- throw new DataStoreReferencingException(e);
+ throw new DataStoreReferencingException(e.getMessage(), e);
}
return resolution;
}
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
index 89ec4751de..06ecde52ab 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/Writer.java
@@ -377,7 +377,7 @@ final class Writer extends IOBase implements Flushable {
geoKeys = new GeoEncoder(store.listeners());
geoKeys.write(grid, mf);
} catch (FactoryException | IncommensurableException |
RuntimeException e) {
- throw new DataStoreReferencingException(e);
+ throw new DataStoreReferencingException(e.getMessage(), e);
}
/*
* Conversion factor from physical size to pixel size. "Physical size"
here should be understood as
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/WriterTest.java
b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/WriterTest.java
index a2f3952b41..23e619a451 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/WriterTest.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/WriterTest.java
@@ -259,8 +259,13 @@ public final class WriterTest extends TestCase {
createGridGeometry();
writeImage();
verifyHeader(false, IOBase.LITTLE_ENDIAN);
- verifyImageFileDirectory(Writer.COMMON_NUMBER_OF_TAGS + 3 - 1,
// 3 more for RGB, 1 less for strips.
- PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO, new short[]
{Byte.SIZE}, false);
+ /*
+ * The number of tags depends on whether an EPSG database is present
or not.
+ * So the test cannot expects an exact number of tags.
+ */
+ int tagCount = data.getShort(data.position());
+ assertTrue(tagCount >= Writer.COMMON_NUMBER_OF_TAGS + 3 - 1);
// 3 more for RGB, 1 less for strips.
+ verifyImageFileDirectory(tagCount,
PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO, new short[] {Byte.SIZE}, false);
verifySampleValues(1);
store.close();
}
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Modules.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Modules.java
index dabfa1a3dd..3b170fdeef 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Modules.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Modules.java
@@ -123,11 +123,6 @@ public final class Modules {
*/
public static final String CLASSNAME_PREFIX = "org.apache.sis.";
- /**
- * The prefix of all internal classnames in Apache SIS, including a
trailing dot.
- */
- public static final String INTERNAL_CLASSNAME_PREFIX = CLASSNAME_PREFIX +
"internal.";
-
/**
* Do not allow instantiation of this class.
*/
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/Classes.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/Classes.java
index b055f6c479..ac05516c74 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/Classes.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/Classes.java
@@ -34,7 +34,6 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Modifier;
import org.opengis.annotation.UML;
import static org.apache.sis.util.collection.Containers.hashMapCapacity;
-import static org.apache.sis.system.Modules.INTERNAL_CLASSNAME_PREFIX;
/**
@@ -55,7 +54,7 @@ import static
org.apache.sis.system.Modules.INTERNAL_CLASSNAME_PREFIX;
* </ul>
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 1.3
+ * @version 1.5
* @since 0.3
*/
public final class Classes extends Static {
@@ -385,7 +384,7 @@ public final class Classes extends Static {
}
}
for (Class<? super T> candidate = type; candidate != null; candidate =
candidate.getSuperclass()) {
- if (Modifier.isPublic(candidate.getModifiers()) &&
!candidate.getName().startsWith(INTERNAL_CLASSNAME_PREFIX)) {
+ if (isPublic(candidate)) {
return candidate;
}
}
@@ -857,4 +856,17 @@ cmp: for (final Class<?> c : c1) {
!method.isSynthetic() &&
!ArraysExt.contains(EXCLUDES, method.getName());
}
+
+ /**
+ * Returns {@code true} if the given class is non-null, public and
exported.
+ *
+ * @param type the class to test, or {@code null}.
+ * @return whether the given class is part of public API.
+ *
+ * @since 1.5
+ */
+ public static boolean isPublic(final Class<?> type) {
+ return (type != null) && Modifier.isPublic(type.getModifiers())
+ && type.getModule().isExported(type.getPackageName());
+ }
}
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/logging/Logging.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/logging/Logging.java
index 016778e170..2dd0681c80 100644
---
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/logging/Logging.java
+++
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/logging/Logging.java
@@ -21,7 +21,6 @@ import java.util.stream.Stream;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.LogRecord;
-import java.lang.reflect.Modifier;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.Static;
import org.apache.sis.util.Exceptions;
@@ -77,12 +76,7 @@ public final class Logging extends Static {
*/
public static Logger getLogger(final Class<?> source) {
ArgumentChecks.ensureNonNull("source", source);
- String name = source.getPackageName();
- if (name.startsWith(Modules.INTERNAL_CLASSNAME_PREFIX)) {
- // Remove the "internal" part from Apache SIS package names.
- name = Modules.CLASSNAME_PREFIX +
name.substring(Modules.INTERNAL_CLASSNAME_PREFIX.length());
- }
- return Logger.getLogger(name);
+ return Logger.getLogger(source.getPackageName());
}
/**
@@ -133,7 +127,7 @@ public final class Logging extends Static {
final Logger fl = logger; // Because lambda functions
require final values.
logger =
StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).walk((stream)
->
inferCaller(fl, (classe != null) ?
classe.getCanonicalName() : null, method,
- stream.filter((frame) ->
Modifier.isPublic(frame.getDeclaringClass().getModifiers()))
+ stream.filter((frame) ->
Classes.isPublic(frame.getDeclaringClass()))
.map((StackWalker.StackFrame::toStackTraceElement)), record));
}
logger.log(record);
@@ -187,17 +181,12 @@ public final class Logging extends Static {
* This method is invoked in order to infer the class and method names to
declare in a {@link LogRecord}.
* We do not document this feature in public Javadoc because it is based
on heuristic rules that may change.
*
- * <p>The current implementation compares the class name against a
hard-coded list of classes to hide.
- * This implementation may change in any future SIS version.</p>
- *
* @param e a stack trace element.
* @return {@code true} if the class and method specified by the given
element can be considered public API.
*/
private static boolean isPublic(final StackTraceElement e) {
final String classname = e.getClassName();
- if (classname.startsWith("java") ||
classname.startsWith(Modules.INTERNAL_CLASSNAME_PREFIX) ||
- classname.indexOf('$') >= 0 || e.getMethodName().indexOf('$') >= 0)
- {
+ if (classname.startsWith("java") || classname.indexOf('$') >= 0 ||
e.getMethodName().indexOf('$') >= 0) {
return false;
}
if (classname.startsWith(Modules.CLASSNAME_PREFIX + "util.logging.")) {