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

[fj-doc-base] Managing of unsafe DocTypeHandler for DocHandlerFactory #31

Closed
fugerit79 opened this issue Feb 26, 2023 · 0 comments · Fixed by #32
Closed

[fj-doc-base] Managing of unsafe DocTypeHandler for DocHandlerFactory #31

fugerit79 opened this issue Feb 26, 2023 · 0 comments · Fixed by #32
Assignees
Labels
enhancement New feature or request

Comments

@fugerit79
Copy link
Member

fugerit79 commented Feb 26, 2023

The class DocHandlerFactory offers a conveniente system to load and register type handler, but if even just one type handler is not found, the load process will fail.

It would be better if it was possible to tag handlers entry as "unsafe" (in which case the factory creations should not safe if the handler is not found).

	<factory id="unsafe-test">
		<data id="html-fm" info="html" type="org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandlerUTF8" />	
		<data id="html-fragment-fm" info="fhtml" type="org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlFragmentTypeHandlerUTF8" />
		<data id="pdf-unsafe" info="pdf" type="org.fugerit.java.doc.pdf.UnsafeDocHandler" />
	</factory>

Imagine the last handler is not available in class loader. Thi can be handled with the new properties :

unsafe="true" unsafeMode="log-trace"

	<factory id="unsafe-test">
		<data id="html-fm" info="html" type="org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandlerUTF8" />	
		<data id="html-fragment-fm" info="fhtml" type="org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlFragmentTypeHandlerUTF8" />
		<data id="pdf-unsafe" info="pdf" type="org.fugerit.java.doc.pdf.UnsafeDocHandler" unsafe="true" unsafeMode="log-trace"/>
	</factory>

The stack trace will be logged only if you set unsafeMod to log-trace. If you want to suppress the stack trace use :

unsafe="true" unsafeMode="log-message"

@fugerit79 fugerit79 self-assigned this Feb 26, 2023
@fugerit79 fugerit79 added the enhancement New feature or request label Feb 26, 2023
fugerit79 added a commit to fugerit-org/fj-lib that referenced this issue Feb 26, 2023
+ [Added unsafe loading for factory
type](fugerit-org/fj-doc#31)
@fugerit79 fugerit79 changed the title [fj-dpc-base] Handling of unsafe type handlers for DocHandlerFactory [fj-doc-base] Handling of unsafe type handlers for DocHandlerFactory Feb 26, 2023
@fugerit79 fugerit79 changed the title [fj-doc-base] Handling of unsafe type handlers for DocHandlerFactory [fj-doc-base] Managing of unsafe DocTypeHandler for DocHandlerFactory Feb 26, 2023
fugerit79 added a commit that referenced this issue Feb 26, 2023
+ [Managing of unsafe DocTypeHandler for
DocHandlerFactory](#31)
+ update fj-core version to 0.8.13 (DocHandlerFactory would not work
with previous versions)
@fugerit79 fugerit79 linked a pull request Feb 26, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant