From: Mathieu Baudier Date: Sat, 22 Oct 2022 10:38:28 +0000 (+0200) Subject: Make adaptation to XML Source more robust X-Git-Tag: v2.3.10~4 X-Git-Url: https://git.argeo.org/?a=commitdiff_plain;h=ceee6c4ebe8e30e19cf3a1cdae3267cbd8840d62;p=gpl%2Fargeo-jcr.git Make adaptation to XML Source more robust --- diff --git a/org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContent.java b/org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContent.java index a4af35b..3059064 100644 --- a/org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContent.java +++ b/org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContent.java @@ -257,12 +257,20 @@ public class JcrContent extends AbstractContent { public A adapt(Class clss) { if (Source.class.isAssignableFrom(clss)) { // try { - PipedInputStream in = new PipedInputStream(); + PipedOutputStream out = new PipedOutputStream(); + PipedInputStream in; + try { + in = new PipedInputStream(out); + } catch (IOException e) { + throw new RuntimeException("Cannot export " + jcrPath + " in workspace " + jcrWorkspace, e); + } ForkJoinPool.commonPool().execute(() -> { - try (PipedOutputStream out = new PipedOutputStream(in)) { +// try (PipedOutputStream out = new PipedOutputStream(in)) { + try { provider.getJcrSession(getSession(), jcrWorkspace).exportDocumentView(jcrPath, out, true, false); out.flush(); + out.close(); } catch (IOException | RepositoryException e) { throw new RuntimeException("Cannot export " + jcrPath + " in workspace " + jcrWorkspace, e); }