Page 1 of 1
Retrieve AuthorAccess in StylesFilter
Posted: Tue Jul 01, 2025 10:27 am
by Isabelle
Hello,
We use oxygen sdk 27.1.0.1.
We have implemented our own StylesFilter and in the override method
public Styles filter(Styles styles, AuthorNode authorNode)
we need AuthorAccess.
For this, we have coded this :
Code: Select all
URL currentUrl = authorNode.getXMLBaseURL();
WSEditor currentPluginEditorAccess = PluginWorkspaceProvider.getPluginWorkspace().getEditorAccess(currentUrl, PluginWorkspace.MAIN_EDITING_AREA);
WSEditorPage currentPage = currentPluginEditorAccess.getCurrentPage();
if(currentPage instanceof WSAuthorEditorPage) {
WSAuthorEditorPage wsAuthorEditorPage = (WSAuthorEditorPage) currentPage;
return wsAuthorEditorPage.getAuthorAccess();
} else {
return null;
}
But when we open a large document, we face a
StackOverflowError error :
java.lang.StackOverflowError: null
at java.base/java.net.URLStreamHandler.parseURL(URLStreamHandler.java:326)
at java.base/sun.net.www.protocol.file.Handler.parseURL(Handler.java:67)
at java.base/java.net.URL.<init>(URL.java:703)
at java.base/java.net.URL.<init>(URL.java:569)
at java.base/java.net.URL.<init>(URL.java:516)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at com._4dconcept.adam.author.framework.S1000D.style.ADAMStylesFilter.getAuthorAccess(ADAMStylesFilter.java:254)
at com._4dconcept.adam.author.framework.S1000D.style.ADAMStylesFilter.filter(ADAMStylesFilter.java:54)
at ro.sync.ecss.css.db.pe(Unknown Source)
at ro.sync.ecss.css.db.xg(Unknown Source)
at ro.sync.ecss.css.db.q(Unknown Source)
...
For information :
ADAMStylesFilter.java:254 refers to
URL currentUrl = authorNode.getXMLBaseURL();
Can you explain to me how to retrieve AuthorAccess properly ?
Thanks,
Regards,
Isabelle
Re: Retrieve AuthorAccess in StylesFilter
Posted: Tue Jul 01, 2025 11:29 am
by Radu
Hi Isabelle,
The StylesFilter does not have access to the current editor for a reason. It may start getting called very early, before the current editor is opened.
In the Javadoc for the StylesFilter class it says:
Code: Select all
* <p>If your StylesFilter implementation also implements the {@link AuthorExtensionStateListener} API, its "activated" callback will be automatically
* called with the corresponding {@link AuthorAccess}.</p>
so this is the proper way to gain access to the AuthorAccess corresponding to it.
But even with using the proper way of retrieving the AuthorAccess, if inside the styles filter you use the authoraccess to try and retrieve the styles for another node, then the same styles filter gets called to compute styles also for that node so you might again end up with a stack overflow.
Regards,
Radu
Re: Retrieve AuthorAccess in StylesFilter
Posted: Tue Jul 01, 2025 3:13 pm
by Isabelle
Thank you Radu for your quick feedback.
I made an other test.
I have this custom StylesFilter :
Code: Select all
public abstract class CustomStylesFilter implements StylesFilter {
public CustomStylesFilter () {
}
@Override
public Styles filter(Styles styles, AuthorNode authorNode) {
if (AuthorNode.NODE_TYPE_ELEMENT == authorNode.getType() && ("nodeName".equals(authorNode.getName()))) {
AuthorElement[] code = ((AuthorElement) authorNode).getElementsByLocalName("code");
if (code != null && code.length > 0) {
String infoCode = code[0].getAttribute("infoCode").getValue();
}
}
return styles;
}
@Override
public String getDescription() {
return null;
}
}
And I style have a StackOverflowError :
java.lang.StackOverflowError: null
at java.base/java.util.WeakHashMap.hash(WeakHashMap.java:303)
at java.base/java.util.WeakHashMap.get(WeakHashMap.java:402)
at ro.sync.ecss.css.db.qc(Unknown Source)
at ro.sync.ecss.css.db.q(Unknown Source)
at ro.sync.ecss.component.f.g.m(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
I delete all references to AuthorAcces and I still have this issue.
Do you have any idea ?
Thanks,
Regards,
Isabelle
Re: Retrieve AuthorAccess in StylesFilter
Posted: Tue Jul 01, 2025 3:25 pm
by Radu
Hi Isabelle,
That looks like a different stack overflow, could you most more content from the stack trace exception? More lines?
Regards,
Radu
Re: Retrieve AuthorAccess in StylesFilter
Posted: Tue Jul 01, 2025 3:52 pm
by Isabelle
Here is the full stack trace :
java.lang.StackOverflowError: null
at java.base/java.util.WeakHashMap.hash(WeakHashMap.java:303)
at java.base/java.util.WeakHashMap.get(WeakHashMap.java:402)
at ro.sync.ecss.css.db.qc(Unknown Source)
at ro.sync.ecss.css.db.q(Unknown Source)
at ro.sync.ecss.component.f.g.m(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
...........
But sometimes I have other errors :
java.lang.StackOverflowError: null
at ro.sync.exml.options.Options.nb(Unknown Source)
at ro.sync.exml.options.Options.ob(Unknown Source)
at ro.sync.exml.options.Options.wb(Unknown Source)
at ro.sync.exml.options.Options.getObject(Unknown Source)
at ro.sync.options.k.getBooleanProperty(Unknown Source)
at ro.sync.ecss.conditions.c.c.k(Unknown Source)
at ro.sync.ecss.conditions.y.ead(Unknown Source)
at ro.sync.ecss.conditions.y.rzc(Unknown Source)
at ro.sync.ecss.css.db.qb(Unknown Source)
at ro.sync.ecss.css.db.xg(Unknown Source)
at ro.sync.ecss.css.db.q(Unknown Source)
at ro.sync.ecss.component.f.g.m(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
...........
Re: Retrieve AuthorAccess in StylesFilter
Posted: Tue Jul 01, 2025 5:15 pm
by Radu
Hi Isabella,
Strange, both these stack overflow stack traces seem to stem from the automatic spell checker, it gets in some kind of a loop, I need to think more about this.
But if you uncomment your styles filter API implementation the problem cannot be reproduced correct? Can you come up with the most basic styles filter implementation that I could use on my side to reproduce the problem?
Regards,
Radu
Re: Retrieve AuthorAccess in StylesFilter
Posted: Tue Jul 01, 2025 5:35 pm
by Isabelle
Hi Radu,
When I comment the method
createAuthorStylesFilter in our CustomExtensionsBundle I still have the issue
java.lang.StackOverflowError: null
at java.base/java.util.WeakHashMap.hash(WeakHashMap.java:303)
at java.base/java.util.WeakHashMap.get(WeakHashMap.java:402)
at ro.sync.ecss.css.db.qc(Unknown Source)
at ro.sync.ecss.css.db.q(Unknown Source)
at ro.sync.ecss.component.f.g.m(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
I can send you the XML file for your test if needed.
Regards,
Isabelle
Re: Retrieve AuthorAccess in StylesFilter
Posted: Wed Jul 02, 2025 8:16 am
by Radu
Hi Isabella,
I added an internal issue to look more into this problem, pasting the issue ID below:
EXM-55974 Stack overflow in spell checker
Yes, if you have a small sample XML + CSS, customizations I could use on my side to reproduce the problem, they would be welcomed, you can use our tech support form:
https://www.oxygenxml.com/techSupport.html
or our support email address.
Regards,
Radu
Re: Retrieve AuthorAccess in StylesFilter
Posted: Wed Jul 02, 2025 7:34 pm
by Isabelle
Hello Radu,
I have just sent a zip file with XML and CSS to reproduce the problem.
Here is the ticket number => OXYGEN-TS-6692.
Feel free to contact me if you need more information.
Regards,
Isabelle
Re: Retrieve AuthorAccess in StylesFilter
Posted: Thu Jul 03, 2025 7:19 am
by Radu
Hi Isabelle,
Thanks for the samples, we'll talk more via email and post here when we get a conclusion.
Regards,
Radu