diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMetadataReader.java b/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMetadataReader.java index 428258cce9..78e7a413ac 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMetadataReader.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMetadataReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.core.type.classreading; +import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; @@ -38,21 +39,25 @@ import org.springframework.core.type.ClassMetadata; final class SimpleMetadataReader implements MetadataReader { private final Resource resource; + private final ClassMetadata classMetadata; + private final AnnotationMetadata annotationMetadata; + SimpleMetadataReader(Resource resource, ClassLoader classLoader) throws IOException { - InputStream is = resource.getInputStream(); + InputStream is = new BufferedInputStream(resource.getInputStream()); ClassReader classReader = null; try { classReader = new ClassReader(is); - } finally { + } + finally { is.close(); } AnnotationMetadataReadingVisitor visitor = new AnnotationMetadataReadingVisitor(classLoader); classReader.accept(visitor, true); - + this.annotationMetadata = visitor; // (since AnnotationMetadataReader extends ClassMetadataReadingVisitor) this.classMetadata = visitor; @@ -70,4 +75,5 @@ final class SimpleMetadataReader implements MetadataReader { public AnnotationMetadata getAnnotationMetadata() { return this.annotationMetadata; } -} \ No newline at end of file + +}