Correction étourderie (NPE), traces supplémentaires et logger.error à la place de printStackTrace
Showing
1 changed file
with
6 additions
and
9 deletions
... | @@ -68,12 +68,11 @@ public class PostprocessingApplication { | ... | @@ -68,12 +68,11 @@ public class PostprocessingApplication { |
68 | sampleItemIds.add(itemId); | 68 | sampleItemIds.add(itemId); |
69 | sampleUserIds.add(userId); | 69 | sampleUserIds.add(userId); |
70 | if (!sampleItemUserIds.containsKey(itemId)) { | 70 | if (!sampleItemUserIds.containsKey(itemId)) { |
71 | - Set<Long> set = sampleItemUserIds.get(itemId); | 71 | + Set<Long> set = new HashSet<>(); |
72 | -// NPE !!! | ||
73 | set.add(userId); | 72 | set.add(userId); |
74 | sampleItemUserIds.put(itemId, set); | 73 | sampleItemUserIds.put(itemId, set); |
75 | } else { | 74 | } else { |
76 | - Set<Long> set = new HashSet<>(); | 75 | + Set<Long> set = sampleItemUserIds.get(itemId); |
77 | set.add(userId); | 76 | set.add(userId); |
78 | sampleItemUserIds.put(itemId, set); | 77 | sampleItemUserIds.put(itemId, set); |
79 | } | 78 | } |
... | @@ -87,10 +86,10 @@ public class PostprocessingApplication { | ... | @@ -87,10 +86,10 @@ public class PostprocessingApplication { |
87 | } | 86 | } |
88 | 87 | ||
89 | logger.trace("Nombre de couples item-user dans l'échantillon {}", sampleCoupleCount); | 88 | logger.trace("Nombre de couples item-user dans l'échantillon {}", sampleCoupleCount); |
89 | + logger.trace("Nombre de couples item-user recommandables {}", sampleItemIds.size() * sampleUserIds.size() - sampleCoupleCount); | ||
90 | 90 | ||
91 | } catch (IOException e) { | 91 | } catch (IOException e) { |
92 | - //fixme use logger instead of e.printStackTrace() !!! | 92 | + logger.error("analyzeSample IOException : {}", e.getStackTrace()); |
93 | - e.printStackTrace(); | ||
94 | } | 93 | } |
95 | 94 | ||
96 | } | 95 | } |
... | @@ -112,8 +111,6 @@ public class PostprocessingApplication { | ... | @@ -112,8 +111,6 @@ public class PostprocessingApplication { |
112 | 111 | ||
113 | void loadParametersProperties() { | 112 | void loadParametersProperties() { |
114 | 113 | ||
115 | - //fixme use logger instead of e.printStackTrace() !!! | ||
116 | - | ||
117 | Properties properties = new Properties(); | 114 | Properties properties = new Properties(); |
118 | InputStream in = null; | 115 | InputStream in = null; |
119 | try { | 116 | try { |
... | @@ -122,9 +119,9 @@ public class PostprocessingApplication { | ... | @@ -122,9 +119,9 @@ public class PostprocessingApplication { |
122 | properties.load(in); | 119 | properties.load(in); |
123 | in.close(); | 120 | in.close(); |
124 | } catch (FileNotFoundException e) { | 121 | } catch (FileNotFoundException e) { |
125 | - e.printStackTrace(); | 122 | + logger.error("analyzeSample FileNotFoundException : {}", e.getStackTrace()); |
126 | } catch (IOException e) { | 123 | } catch (IOException e) { |
127 | - e.printStackTrace(); | 124 | + logger.error("analyzeSample IOException : {}", e.getStackTrace()); |
128 | } | 125 | } |
129 | 126 | ||
130 | this.properties = properties; | 127 | this.properties = properties; | ... | ... |
-
Please register or login to post a comment