diff --git a/source/java/org/alfresco/opencmis/AlfrescoCmisStreamInterceptor.java b/source/java/org/alfresco/opencmis/AlfrescoCmisStreamInterceptor.java index 35953e6d56..8f755c5f9e 100644 --- a/source/java/org/alfresco/opencmis/AlfrescoCmisStreamInterceptor.java +++ b/source/java/org/alfresco/opencmis/AlfrescoCmisStreamInterceptor.java @@ -54,7 +54,7 @@ public class AlfrescoCmisStreamInterceptor implements MethodInterceptor Object[] arguments = mi.getArguments(); for (int i = 0; i < parameterTypes.length; i++) { - if (parameterTypes[i].isAssignableFrom(ContentStreamImpl.class)) + if (arguments[i] instanceof ContentStreamImpl) { ContentStreamImpl contentStream = (ContentStreamImpl) arguments[i]; if (contentStream != null) diff --git a/source/test-java/org/alfresco/opencmis/CMISTest.java b/source/test-java/org/alfresco/opencmis/CMISTest.java index f8b1f7af13..4a017e6ed2 100644 --- a/source/test-java/org/alfresco/opencmis/CMISTest.java +++ b/source/test-java/org/alfresco/opencmis/CMISTest.java @@ -78,9 +78,11 @@ import org.apache.chemistry.opencmis.commons.enums.CmisVersion; import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships; import org.apache.chemistry.opencmis.commons.enums.VersioningState; import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException; import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; +import org.apache.chemistry.opencmis.commons.impl.dataobjects.ExtensionDataImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl; @@ -639,6 +641,37 @@ public class CMISTest } } + /** + * ALF-20389 Test Alfresco cmis stream interceptor that checks content stream for mimetype. Only ContentStreamImpl extensions should take palace. + */ + @Test + public void testGetRepositoryInfos() + { + boolean cmisEx = false; + List infoDataList = null; + try + { + infoDataList = withCmisService(new CmisServiceCallback>() + { + @Override + public List execute(CmisService cmisService) + { + ExtensionDataImpl result = new ExtensionDataImpl(); + List extensions = new ArrayList(); + result.setExtensions(extensions); + + return cmisService.getRepositoryInfos(result); + } + }); + } + catch (CmisRuntimeException e) + { + cmisEx = true; + } + + assertNotNull(cmisEx ? "CmisRuntimeException was thrown. Please, take a look on ALF-20389" : "No CMIS repository information was retrieved", infoDataList); + } + private static class TestContext { private String repositoryId = null;