1
1
/*
2
- * Copyright 2002-2009 the original author or authors.
2
+ * Copyright 2002-2012 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
16
16
17
17
package org .springframework .core .type .classreading ;
18
18
19
+ import java .io .BufferedInputStream ;
19
20
import java .io .IOException ;
20
21
import java .io .InputStream ;
21
22
38
39
final class SimpleMetadataReader implements MetadataReader {
39
40
40
41
private final Resource resource ;
42
+
41
43
private final ClassMetadata classMetadata ;
44
+
42
45
private final AnnotationMetadata annotationMetadata ;
43
46
47
+
44
48
SimpleMetadataReader (Resource resource , ClassLoader classLoader ) throws IOException {
45
- InputStream is = resource .getInputStream ();
49
+ InputStream is = new BufferedInputStream ( resource .getInputStream () );
46
50
ClassReader classReader = null ;
47
51
try {
48
52
classReader = new ClassReader (is );
49
- } finally {
53
+ }
54
+ finally {
50
55
is .close ();
51
56
}
52
57
53
58
AnnotationMetadataReadingVisitor visitor = new AnnotationMetadataReadingVisitor (classLoader );
54
59
classReader .accept (visitor , true );
55
-
60
+
56
61
this .annotationMetadata = visitor ;
57
62
// (since AnnotationMetadataReader extends ClassMetadataReadingVisitor)
58
63
this .classMetadata = visitor ;
@@ -70,4 +75,5 @@ public ClassMetadata getClassMetadata() {
70
75
public AnnotationMetadata getAnnotationMetadata () {
71
76
return this .annotationMetadata ;
72
77
}
73
- }
78
+
79
+ }
0 commit comments