NPE试图从ClassDefinitions中获取MethodDefinitions;怎么诊断?

时间:2015-07-29 06:17:02

标签: java intersystems-cache

环境:

  • caché服务器是x86_64 SuSE Linux Enterprise服务器;据我所知,安装是一些2014.x版本;
  • 我有SSH访问机器,但没有任何网络(VPN,你知道);
  • 客户端是Debian Jessie机器;
  • 客户端代码使用cachedb.jar 2015.2版本以Java编写。

我正在做的是为ObjectScript编写一个SonarQube插件,它运行得很好......除非它没有。

我所做的是将所有ClientMethod与langauge JavaScript分离到他们自己的文件中,以便SonarQube JS插件可以分析它们,为此我使用此方法来收集相关方法:

@SuppressWarnings("unchecked")
private List<MethodDefinition> readJsMethods(final boolean ignoreFailures)
    throws CacheException
{
    final Map<String, MethodDefinition> map;
    try {
        map = classDef.getMethods(); // classDef is a ClassDefiniton
    } catch (CacheException e) {
        if (ignoreFailures) {
            LOGGER.error("Failed to obtain methods for class {}, ignored",
                className);
            return Collections.emptyList();
        }
        throw e;
    }

    final List<MethodDefinition> ret = new ArrayList<>();

    MethodDefinition definition;
    boolean failure = false;

    for (final Map.Entry<String, MethodDefinition> entry: map.entrySet()) {
        definition = entry.getValue();
        if (definition == null) { // <-- PROBLEM HERE
            LOGGER.error("Null method definition! Class {}, key {}",
                className, entry.getKey());
            if (ignoreFailures) {
                LOGGER.warn("Failures are ignored; returning no methods");
                return Collections.emptyList();
            }
            failure = true;
            continue;
        }
        if ("javascript".equalsIgnoreCase(definition.getLanguage()))
            ret.add(definition);
    }

    if (failure)
        throw new SqcaException("one or more method definitions are null"
            + " for class " + className);

    Collections.sort(ret, Comparator.comparing(BY_SEQUENCE));
    return ret;
}

在标记为// <-- PROBLEM HERE的行上,可能会发生定义确实为空。更重要的是,Map的确切ClassDefinition和键从一次运行到另一次运行从不相同

我已经尝试过重新启动Caché服务器和整个VM(我有root访问权限),但结果不会改变。

我怀疑这是服务器端的问题,但我不知道如何诊断它,更重要的是,如何解决它。并且这段代码在突然失败之前已经完美运行了好几周......当它开始失败时它总是会失败,总是在一些随机类中随机的方法......

如果我知道我根本无法访问Caché网站管理门户,我如何诊断?

样本堆栈跟踪:

Jul 27, 2015 7:03:57 AM com.roche.sqca.read.Main main
INFO: Loading properties from sqca.properties
Jul 27, 2015 7:03:58 AM com.roche.sqca.read.CacheDbReader getAllClasses
INFO: Reading list of classes from database

Jul 27, 2015 7:04:27 AM com.roche.sqca.read.CacheDbReader getAllClasses
INFO: Result: 12296 total classes, 6920 included, 5376 excluded
Jul 27, 2015 7:04:27 AM com.roche.sqca.read.CosSourceWriter processClasses
INFO: Writing COS class files (directory: /home/sonar/.jenkins/jobs/Infinity/workspace)

Jul 27, 2015 7:04:57 AM com.roche.sqca.read.JsSourceWriter processClasses
INFO: Writing JavaScript client methods, if any (directory: /home/sonar/.jenkins/jobs/Infinity/workspace)

Jul 27, 2015 7:06:23 AM com.roche.sqca.read.CosClass readJsMethods
SEVERE: Null method definition! Class LISPages.WorkArea.Monitoring, key 19
Exception in thread "main" com.roche.sqca.read.SqcaException: one or more method definitions are null for class LISPages.WorkArea.Monitoring
    at com.roche.sqca.read.CosClass.readJsMethods(CosClass.java:199)
    at com.roche.sqca.read.CosClass.getJsMethods(CosClass.java:131)
    at com.roche.sqca.read.JsSourceWriter.processClasses(JsSourceWriter.java:96)
    at com.roche.sqca.read.Main.main(Main.java:142)
Build step 'Execute shell' marked build as failure
Finished: FAILURE

当我实际忽略失败时,这是一个跟踪(上面代码中的ignoreFailures设置为true):

Jul 29, 2015 8:38:10 AM com.roche.sqca.read.Main main
INFO: Loading properties from sqca.properties
Jul 29, 2015 8:38:11 AM com.roche.sqca.read.CacheDbReader getAllClasses
INFO: Reading list of classes from database
Jul 29, 2015 8:38:33 AM com.roche.sqca.read.CacheDbReader getAllClasses
INFO: Result: 12296 total classes, 6920 included, 5376 excluded
Jul 29, 2015 8:38:33 AM com.roche.sqca.read.CosSourceWriter processClasses
INFO: Writing COS class files (directory: /home/sonar/.jenkins/jobs/Infinity/workspace)
Jul 29, 2015 8:39:03 AM com.roche.sqca.read.JsSourceWriter processClasses
INFO: Writing JavaScript client methods, if any (directory: /home/sonar/.jenkins/jobs/Infinity/workspace)
Jul 29, 2015 8:40:17 AM com.roche.sqca.read.CosClass readJsMethods
SEVERE: Null method definition! Class LISPages.WorkArea.Monitoring, key 109
Jul 29, 2015 8:40:17 AM com.roche.sqca.read.CosClass readJsMethods
WARNING: Failures are ignored; returning no methods
# 4 other similar messages for other classes.
# And them, BOOM:
Exception in thread "main" java.sql.SQLException: Invalid Message Count (452); expected: 95590 got: 1163022164. Connection closed
    at com.intersys.jdbc.InStream.invalidMessageReceived(InStream.java:308)
    at com.intersys.jdbc.InStream.checkHeader(InStream.java:108)
    at com.intersys.jdbc.InStream.readHeader(InStream.java:147)
    at com.intersys.jdbc.CacheConnection.sendCustomMessage(CacheConnection.java:1404)
    at com.intersys.cache.jbind.CustomMsgDBAdapter.sendCustomMessage(CustomMsgDBAdapter.java:922)
    at com.intersys.cache.jbind.CustomMsgDBAdapter.getObjectArrayElements(CustomMsgDBAdapter.java:655)
    at com.intersys.cache.jbind.JBindDatabase.getObjectArrayBuffer(JBindDatabase.java:632)
    at com.intersys.classes.ObjectArrayBuffer.getArrayBuffer(ArrayOfObjects.java:296)
    at com.intersys.classes.ArrayBuffer.load(ArrayBuffer.java:407)
    at com.intersys.classes.ArrayBuffer.getNext(ArrayBuffer.java:199)
    at com.intersys.classes.ArrayBuffer._getNext(ArrayBuffer.java:568)
    at com.intersys.classes.AbstractCacheArray._getNext(AbstractCacheArray.java:465)
    at com.intersys.classes.AbstractCacheArray._getFirst(AbstractCacheArray.java:455)
    at com.intersys.classes.AbstractCacheArray$EntryIterator.<init>(AbstractCacheArray.java:153)
    at com.intersys.classes.AbstractCacheArray$EntrySet.iterator(AbstractCacheArray.java:239)
    at com.roche.sqca.read.CosClass.readJsMethods(CosClass.java:182)
    at com.roche.sqca.read.CosClass.getJsMethods(CosClass.java:131)
    at com.roche.sqca.read.JsSourceWriter.processClasses(JsSourceWriter.java:96)
    at com.roche.sqca.read.Main.main(Main.java:142)
com.intersys.objects.CacheServerException: Failed to get elements of array with oref 57323 caused by: java.sql.SQLException: Invalid Message Count (452); expected: 95590 got: 1163022164. Connection closedUnderlying exception: java.sql.SQLException: Invalid Message Count (452); expected: 95590 got: 1163022164. Connection closed

    at com.intersys.cache.jbind.CustomMsgDBAdapter.getObjectArrayElements(CustomMsgDBAdapter.java:660)
    at com.intersys.cache.jbind.JBindDatabase.getObjectArrayBuffer(JBindDatabase.java:632)
    at com.intersys.classes.ObjectArrayBuffer.getArrayBuffer(ArrayOfObjects.java:296)
    at com.intersys.classes.ArrayBuffer.load(ArrayBuffer.java:407)
    at com.intersys.classes.ArrayBuffer.getNext(ArrayBuffer.java:199)
    at com.intersys.classes.ArrayBuffer._getNext(ArrayBuffer.java:568)
    at com.intersys.classes.AbstractCacheArray._getNext(AbstractCacheArray.java:465)
    at com.intersys.classes.AbstractCacheArray._getFirst(AbstractCacheArray.java:455)
    at com.intersys.classes.AbstractCacheArray$EntryIterator.<init>(AbstractCacheArray.java:153)
    at com.intersys.classes.AbstractCacheArray$EntrySet.iterator(AbstractCacheArray.java:239)
    at com.roche.sqca.read.CosClass.readJsMethods(CosClass.java:182)
    at com.roche.sqca.read.CosClass.getJsMethods(CosClass.java:131)
    at com.roche.sqca.read.JsSourceWriter.processClasses(JsSourceWriter.java:96)
    at com.roche.sqca.read.Main.main(Main.java:142)

0 个答案:

没有答案