Make adaptation to XML Source more robust
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 22 Oct 2022 10:38:28 +0000 (12:38 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 22 Oct 2022 10:38:28 +0000 (12:38 +0200)
org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContent.java

index a4af35bc671437ad6b3d9d587817181a9ab7a480..30590640e05cc6a29b43f5b22eeeb90863a2b7a5 100644 (file)
@@ -257,12 +257,20 @@ public class JcrContent extends AbstractContent {
        public <A> A adapt(Class<A> 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);
                                }