diff --git a/after/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java b/after/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java index 08c9b34..faadf3f 100644 --- a/after/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java +++ b/after/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java @@ -157,8 +157,10 @@ public void addInitializer(final String name, final BackgroundInitializer bac protected int getTaskCount() { int result = 1; - for (final BackgroundInitializer bi : childInitializers.values()) { - result += bi.getTaskCount(); + synchronized (this) { + for (final BackgroundInitializer bi : childInitializers.values()) { + result += bi.getTaskCount(); + } } return result; diff --git a/report.pdf b/report.pdf index 199e9eb..933bcbb 100644 Binary files a/report.pdf and b/report.pdf differ diff --git a/report.tex b/report.tex index 1c2ea47..22708b9 100644 --- a/report.tex +++ b/report.tex @@ -8,6 +8,7 @@ \usepackage{xcolor} \usepackage{lmodern} \usepackage{booktabs} +\usepackage{multirow} \usepackage{graphicx} \usepackage{float} \usepackage{tikz} @@ -92,10 +93,10 @@ I choose to analyze version 3.12.0 of the library (i.e.\ the code under the version analyzed during the SDM class. To verify that the project satisfies the 5000 lines of code requirement, I run -the \textit{cloc} tool. Results are shown in figure \ref{fig:cloc}. Given the +the \textit{cloc} tool. Results are shown in table \ref{tab:cloc}. Given the project has more than 118,000 lines of code, this requirement is satisfied. -\begin{figure}[ht] +\begin{table}[ht] \centering \begin{tabular}{lrrrr} \toprule @@ -119,8 +120,8 @@ project has more than 118,000 lines of code, this requirement is satisfied. \end{tabular} \caption{Output of the \textit{cloc} tool for the Apache Commons Lang project at tag \textit{rel/commons-lang-3.12.0} (before fixes are applied).} - \label{fig:cloc} -\end{figure} + \label{tab:cloc} +\end{table} \section{Running the Infer tool} @@ -136,5 +137,53 @@ automatically run the Infer tool using default options through the course tools docker image \textit{bugcounting/satools:y23}. The analysis outputs are located in \textit{before/infer-out/report.txt}. +\section{Results} + +Table \ref{tab:infer} shows the results of the analysis performed by Infer +providing comments on true and false positives and the actions taken for each +result. + +In total + +\begin{table}[] + \small + \begin{tabular}{@{}llp{1.2cm}p{0.8cm}p{6cm}@{}} +\toprule + \textbf{File} & \textbf{Line} & \textbf{Kind} & \textbf{True Pos.} & + \textbf{Comment} \\ \midrule +AnnotationUtils.java & 72 & Null & Yes & -- \\ +reflect/MethodUtils.java & 486 & Null & Yes & -- \\ +reflect/FieldUtils.java & 126 & Null & Yes & -- \\ +concurrent/MultiBackgroundInitializer.java & 160 & Thread Safety & Yes & -- \\ +\midrule +builder/ToStringBuilder.java & 223 & Null & ?? & \multirow{2}{6cm}{??} \\ +builder/ReflectionToStringBuilder.java & 131 & Null & No & \\ +\midrule +time/DurationUtils.java & 142 & Null & No & The method which may return a null + value returns a non-null value if its parameter is non-null, and a + non-null parameter is given \\ +\midrule + CharSetUtils.java & 181 & Null & No & According to \textit{java.lang} documentation, the + method always returns a non-null value \\ +\midrule +reflect/FieldUtils.java & 341 & Null & No & + \multirow{4}{6cm}{a utility method is used to guard the dereference reported + with an exception throw} \\ + reflect/FieldUtils.java & 385 & Null & No & \\ + reflect/FieldUtils.java & 599 & Null & No & \\ + reflect/FieldUtils.java & 644 & Null & No & \\ +\midrule +reflect/MethodUtils.java & 987 & Null & No & The method which may return a null + value returns a non-null value if its parameter is non-null, and a + non-null parameter is always given according to the \textit{java.lang} + documentation for the inner nested method \\ \bottomrule +\end{tabular} + \caption{Results of the Infer static analysis tool execution with default + options. \textit{True Pos.} denotes whether a result is a true positive, + while \textit{Kind} denotes with \textit{Null} and \textit{Thread Safety} + respectively null dereference issues and thread safety violations.} + \label{tab:infer} +\end{table} + \end{document}