Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[smila-dev] Exception as control flow... nono

Hi Guys,

 

i have seen strange warning within our logs (during test execution)

 

2008-10-14 17:54:43,071 [ODEServerImpl-7] INFO  bpel.ProcessingServiceManager - SimpleMimeTypeIdentifierPipeline/extensionActivity-activity-line-35: invoking service SimpleMimeTypeIdentifier, processing request -> request

 2008-10-14 17:54:43,078 [main] WARN  impl.BlackboardServiceImpl - Error while invalidating record: Record with idHash = 75264fad2731bfe3eff94ffd92c6ff749036fc2526f85c2615cd18695e4bf is not loaded in the blackboard.

 2008-10-14 17:54:43,085 [ODEServerImpl-8] INFO  bpel.ProcessingServiceManager - SimpleMimeTypeIdentifierPipeline/extensionActivity-activity-line-35: invoking service SimpleMimeTypeIdentifier, processing request -> request

 2008-10-14 17:54:43,089 [main] WARN  impl.BlackboardServiceImpl - Error while invalidating record: Record with idHash = 367e113d1d9529bbda1a2e8cc5a16eadbb9eb467be375f1fbdde57393dc347 is not loaded in the blackboard.

 2008-10-14 17:54:43,092 [ODEServerImpl-9] INFO  bpel.ProcessingServiceManager - SimpleMimeTypeIdentifierPipeline/extensionActivity-activity-line-35: invoking service SimpleMimeTypeIdentifier, processing request -> request

 2008-10-14 17:54:43,098 [main] WARN  impl.BlackboardServiceImpl - Error while invalidating record: Record with idHash = b46bfb67fe1433714dcdc414665f99b71d4d297db883c9cedccad31e5921 is not loaded in the blackboard.

 

 

I have found the usage of exceptions as control flow. I am 100% sure you know better. This approach cost lot of performance.

 

  /**

   * {@inheritDoc}

   */

  public void invalidate(final Id id) {

    // TODO: unlock the record in database.

    try {

      _xssConnection.getDocument(id.getIdHash());

    } catch (final XssException exception) {

      if (XssExceptionType.DOCUMENT_NOT_FOUND.equals(exception.getXssExceptionType())) {

        try {

          final Record record = getCachedRecord(id);

          if (record.hasAttachments()) {

            for (final Iterator<String> attachmentNames = record.getAttachmentNames(); attachmentNames.hasNext();) {

              final String attachmentName = attachmentNames.next();

              _binaryStorage.delete(getAttachmentId(id, attachmentName));

            }

          }

        } catch (final BlackboardAccessException blackboardException) {

          _log.warn("Error while invalidating record: " + blackboardException.getMessage());

        } catch (final BinaryStorageException bsex) {

          if (_log.isErrorEnabled()) {

            _log.error("Could not invalidate/delete the attachment-file from binary storage for record having id :"

              + id.getIdHash() + " - " + bsex.getMessage());

          }

        }

      }

    } finally {

      _recordMap.remove(id);

    }

  }

 

 

The issue is generated by calling the getCachedRecord() Method

 

 

  /**

   * Returns the record by id.

   *

   * @param id

   *          the id

   *

   * @return the record

   *

   * @throws BlackboardAccessException

   *           the blackboard access exception

   */

  private Record getCachedRecord(final Id id) throws BlackboardAccessException {

    if (!_recordMap.containsKey(id)) {

      throw new BlackboardAccessException("Record with idHash = " + id.getIdHash()

        + " is not loaded in the blackboard.");

    }

    return _recordMap.get(id);

  }

 

I do not want to make this change by myself, because I have not made this implementation. Could you please improve this point.

 

Thanks,

 

Georg

 


Back to the top