Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalStateException in NCXChecker #666

Closed
tofi86 opened this issue Dec 25, 2015 · 1 comment · Fixed by #785
Closed

java.lang.IllegalStateException in NCXChecker #666

tofi86 opened this issue Dec 25, 2015 · 1 comment · Fixed by #785
Labels
status: has PR The issue is being processed in a pull request type: bug The issue describes a bug
Milestone

Comments

@tofi86
Copy link
Collaborator

tofi86 commented Dec 25, 2015

Happens with test epub Issue21.epub from the testsuite within this repository with epubcheck 4.0.1:

→ java -Duser.language=en -jar epubcheck.jar src/test/resources/20/epub/Issue21.epub 
Validating using EPUB version 2.0.1 rules.
WARNING(OPF-055): ../src/test/resources/20/epub/Issue21.epub/OEBPS/content.opf(4,13): title tag is empty.
ERROR(OPF-054): ../src/test/resources/20/epub/Issue21.epub/OEBPS/content.opf(9,12): Date value '' is not valid as per http://www.w3.org/TR/NOTE-datetime:zero-length string.
ERROR(OPF-050): ../src/test/resources/20/epub/Issue21.epub/OEBPS/content.opf(22,75): TOC attribute references resource with non-NCX mime type; 'application/x-dtbncx+xml' is expected.
java.lang.IllegalStateException
    at com.google.common.base.Preconditions.checkState(Preconditions.java:133)
    at com.adobe.epubcheck.ncx.NCXChecker.<init>(NCXChecker.java:44)
    at com.adobe.epubcheck.ncx.NCXCheckerFactory.newInstance(NCXCheckerFactory.java:35)
    at com.adobe.epubcheck.opf.OPFChecker.checkItemContent(OPFChecker.java:420)
    at com.adobe.epubcheck.opf.OPFChecker.runChecks(OPFChecker.java:157)
    at com.adobe.epubcheck.ocf.OCFChecker.runChecks(OCFChecker.java:300)
    at com.adobe.epubcheck.api.EpubCheck.doValidate(EpubCheck.java:215)
    at com.adobe.epubcheck.tool.EpubChecker.validateFile(EpubChecker.java:160)
    at com.adobe.epubcheck.tool.EpubChecker.processFile(EpubChecker.java:494)
    at com.adobe.epubcheck.tool.EpubChecker.run(EpubChecker.java:254)
    at com.adobe.epubcheck.tool.Checker.main(Checker.java:31)
epubcheck completed
@tofi86 tofi86 added type: bug The issue describes a bug status: needs review Needs to be reviewed by a team member before further processing labels Dec 25, 2015
@rdeltour rdeltour added this to the Next milestone Dec 28, 2015
@rdeltour rdeltour self-assigned this Dec 28, 2015
@santoch
Copy link

santoch commented Jan 27, 2016

Related to this bug:
There are many cases where the Preconditions.checkState method is called.
These are essentially asserts that halt the execution of the process if the condition is not met.
I think we should consider changing these to non-halting checks with error messages when they are due to mis-configured epub content. I would think that the null checks are ok, as long as the nulls are NOT expected (ie, looking something up but failing to find it may be an expected result, so we would NOT want to assert and halt in that case)

Here's the list of assertions besides the without the null checks:

./src/main/java/com/adobe/epubcheck/ocf/OCFChecker.java:104: Preconditions.checkState(context.ocf.isPresent());
./src/main/java/com/adobe/epubcheck/nav/NavChecker.java:77: Preconditions.checkState("application/xhtml+xml".equals(context.mimeType));
./src/main/java/com/adobe/epubcheck/dtbook/DTBookChecker.java:44: Preconditions.checkState("application/x-dtbook+xml".equals(context.mimeType));
./src/main/java/com/adobe/epubcheck/opf/MetadataSet.java:473: Preconditions.checkArgument(meta.getId().isPresent());
./src/main/java/com/adobe/epubcheck/opf/OPFHandler.java:678: Preconditions.checkState(items == null);
./src/main/java/com/adobe/epubcheck/opf/ResourceCollection.java:233: Preconditions.checkState(roles != null);
./src/main/java/com/adobe/epubcheck/ncx/NCXChecker.java:44: Preconditions.checkState("application/x-dtbncx+xml".equals(context.mimeType));
./src/main/java/com/adobe/epubcheck/overlay/OverlayChecker.java:45: Preconditions.checkState("application/smil+xml".equals(context.mimeType));
./src/main/java/com/adobe/epubcheck/dict/SearchKeyMapChecker.java:45: Preconditions.checkState("application/vnd.epub.search-key-map+xml".equals(context.mimeType));

NotNull checks:
./src/main/java/com/adobe/epubcheck/ocf/OCFPackage.java:35: Preconditions.checkNotNull(reporter);
./src/main/java/com/adobe/epubcheck/ocf/OCFPackage.java:52: Preconditions.checkNotNull(reporter);
./src/main/java/com/adobe/epubcheck/api/EPUBLocation.java:45: Preconditions.checkNotNull(path);
./src/main/java/com/adobe/epubcheck/api/FeatureReport.java:95: Preconditions.checkNotNull(name);
./src/main/java/com/adobe/epubcheck/api/FeatureReport.java:96: Preconditions.checkNotNull(location);
./src/main/java/com/adobe/epubcheck/dtbook/DTBookHandler.java:150: return new URI(Preconditions.checkNotNull(uri).trim());
./src/main/java/com/adobe/epubcheck/vocab/Property.java:74: Preconditions.checkNotNull(clazz);
./src/main/java/com/adobe/epubcheck/vocab/VocabUtil.java:104: Preconditions.checkNotNull(vocabs);
./src/main/java/com/adobe/epubcheck/vocab/VocabUtil.java:105: Preconditions.checkNotNull(report);
./src/main/java/com/adobe/epubcheck/vocab/VocabUtil.java:106: Preconditions.checkNotNull(location);
./src/main/java/com/adobe/epubcheck/vocab/EnumVocab.java:114: Preconditions.checkNotNull(property);
./src/main/java/com/adobe/epubcheck/ops/OPSHandler.java:421: return new URI(Preconditions.checkNotNull(uri).trim());
./src/main/java/com/adobe/epubcheck/opf/MetadataSet.java:230: Preconditions.checkNotNull(metas);
./src/main/java/com/adobe/epubcheck/opf/MetadataSet.java:231: Preconditions.checkNotNull(property);
./src/main/java/com/adobe/epubcheck/opf/MetadataSet.java:232: Preconditions.checkNotNull(value);
./src/main/java/com/adobe/epubcheck/opf/MetadataSet.java:265: Preconditions.checkNotNull(metas);
./src/main/java/com/adobe/epubcheck/opf/MetadataSet.java:266: Preconditions.checkNotNull(property);
./src/main/java/com/adobe/epubcheck/opf/MetadataSet.java:267: Preconditions.checkNotNull(value);
./src/main/java/com/adobe/epubcheck/opf/MetadataSet.java:295: Preconditions.checkNotNull(property);
./src/main/java/com/adobe/epubcheck/opf/OPFItem.java:302: this.id = Preconditions.checkNotNull(id).trim();
./src/main/java/com/adobe/epubcheck/opf/OPFItem.java:303: this.path = Preconditions.checkNotNull(path).trim();
./src/main/java/com/adobe/epubcheck/opf/ValidationContext.java:214: properties.add(Preconditions.checkNotNull(property));
./src/main/java/com/adobe/epubcheck/opf/XRefChecker.java:185: Resource res = Preconditions.checkNotNull(resources.get(path));
./src/main/java/com/adobe/epubcheck/opf/OPFItems.java:78: this.items = ImmutableList.copyOf(Preconditions.checkNotNull(items));
./src/main/java/com/adobe/epubcheck/opf/OPFItems.java:113: return new OPFItems(Iterables.transform(Preconditions.checkNotNull(itemBuilders),
./src/main/java/com/adobe/epubcheck/opf/OPFItems.java:121: }), Preconditions.checkNotNull(spineIDs));

@tofi86 tofi86 removed the status: needs review Needs to be reviewed by a team member before further processing label Feb 11, 2017
takahashim added a commit to takahashim/epubcheck-idpf that referenced this issue Aug 15, 2017
takahashim added a commit to takahashim/epubcheck-idpf that referenced this issue Aug 15, 2017
@tofi86 tofi86 added the status: has PR The issue is being processed in a pull request label Aug 15, 2017
tofi86 pushed a commit that referenced this issue Sep 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: has PR The issue is being processed in a pull request type: bug The issue describes a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants