cancel
Showing results for 
Search instead for 
Did you mean: 

Bug: Too many open files after enabling Audit

dnc
Champ in-the-making
Champ in-the-making
Hi,

I'm getting an error (too many open files) after enabling Audit in Alfresco Labs 3b.

To solve this problem I closed streams in method getAuditConfig() in HibernateAuditDAO.java

private AuditConfig getAuditConfig(final AuditState auditInfo)
    {

        AuditConfig auditConfig;
        auditConfig = queryLatestConfig(getSession());
        if (auditConfig == null)
        {
            auditConfig = createNewAuditConfigImpl(auditInfo);
        }
        else
        {

            InputStream current = new BufferedInputStream(auditInfo.getAuditConfiguration().getInputStream());
            ContentReader reader = contentStore.getReader(auditConfig.getConfigURL());
            reader.setMimetype(MimetypeMap.MIMETYPE_XML);
            reader.setEncoding("UTF-8");
            InputStream last = new BufferedInputStream(reader.getContentInputStream());
            int currentValue = -2;
            int lastValue = -2;
            try
            {
                while ((currentValue != -1) && (lastValue != -1) && (currentValue == lastValue))
                {
                    currentValue = current.read();
                    lastValue = last.read();

                }
            }
            catch (IOException e)
            {
                throw new AlfrescoRuntimeException("Failed to read and validate current audit configuration against the last", e);
            } finally {

                try {
                    current.close();
                    last.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            if (currentValue != lastValue)
            {
                // Files are different - require a new entry
                auditConfig = createNewAuditConfigImpl(auditInfo);
            }
            else
            {
                // No change
            }
        }

        return auditConfig;

    }
4 REPLIES 4

andy
Champ on-the-rise
Champ on-the-rise
Hi

This over-sight has been fixed on 2.1 and will merge its way forward.

Andy

alar
Champ in-the-making
Champ in-the-making
Is this bug registered in Alfresco issue tracker? Could you please provide the link for this issue in your issue tracker.

rivarola
Champ on-the-rise
Champ on-the-rise
Hello,

Same problem for Alfresco 2.2E. Please remember to apply this fix also on the 2.2 versions.

andy
Champ on-the-rise
Champ on-the-rise
Hi

This fix will be merged forward as normal and will be in the next 2.2.x release after the fix.

Andy