diff --git a/java/core/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java index dc5e45a9f09e9..cffb18151dc7e 100644 --- a/java/core/src/main/java/com/google/protobuf/Descriptors.java +++ b/java/core/src/main/java/com/google/protobuf/Descriptors.java @@ -2180,9 +2180,9 @@ public FileDescriptor getFile() { * present in all runtimes; as of writing, we know that: * * * *

Care should be taken when using this function to respect the target runtime's enum @@ -2890,7 +2890,7 @@ void resolveFeatures(FeatureSet unresolvedFeatures) throws DescriptorValidationE this, "Failed to parse features with Java feature extension registry.", e); } } - + FeatureSet.Builder features; if (this.parent == null) { Edition edition = getFile().getEdition(); @@ -2922,6 +2922,13 @@ FeatureSet getFeatures() { || getFile().getEdition() == Edition.EDITION_PROTO3)) { getFile().resolveAllFeaturesImmutable(); } + if (this.features == null) { + throw new NullPointerException( + String.format( + "Features not yet loaded for %s. This may be caused by a known issue for proto2" + + " dependency descriptors obtained from proto1 (b/362326130)", + getFullName())); + } return this.features; }