From ceee6c4ebe8e30e19cf3a1cdae3267cbd8840d62 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Sat, 22 Oct 2022 12:38:28 +0200 Subject: [PATCH] Make adaptation to XML Source more robust --- .../src/org/argeo/cms/jcr/acr/JcrContent.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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); } -- 2.30.2