redundant null-check

Issue #77 new
Michael Eichberg repo owner created an issue
try
                {
                    Method classMethod = null;

                    // Use the transaction data to get the name of the method to be executed via reflection
                    if ((transaction.getParameterTypes() != null) && (transaction.getParameterTypes().length != 0))
                    {
                        classMethod = this.getClass().getMethod(transaction.getMethod(),
                                                                convertClassNames(transaction.getParameterTypes()));
                    }
                    else
                    {
                        classMethod = this.getClass().getMethod(transaction.getMethod(), (Class[]) null);
                    }

                    if (classMethod != null)
                    {
                    ...
                    }
                    else
                    {
                    ...
                    }
catch { ... }

In case of the second access of classMethod (a field) the value should no longer be null; because getMethod never returns "null" (if the method is not concurrently accessed!)

Comments (3)

  1. Log in to comment