Project

Profile

Help

Revision 306962bc

Added by O'Neil Delpratt 5 months ago

Saxon/C development - Added multi-threading test case and other bug fixes

View differences:

src/main/c/Saxon.C.API/SaxonProcessor.cpp
58 58
}
59 59

  
60 60
void SaxonProcessor::exceptionClear() {
61
    SaxonProcessor::sxn_environ->env->ExceptionClear();
61
    if(exceptionOccurred()) {
62
        SaxonProcessor::sxn_environ->env->ExceptionClear();
63
    }
64
    if (exception != nullptr) {
65
        delete exception;
66
    }
62 67

  
63 68
}
64 69

  
......
72 77
    return NULL;
73 78
}
74 79

  
80
void SaxonProcessor::createException(const char * message) {
81

  
82
    if(exceptionOccurred()) {
83
        delete exception;
84
        SaxonProcessor::sxn_environ->env->ExceptionClear();
85
    }
86

  
87
    if(message == nullptr) {
88
        exception = checkAndCreateException(saxonCAPIClass);
89
    } else {
90
        exception = new SaxonApiException(message);
91
    }
92

  
93
}
94

  
75 95

  
76
SaxonApiException *SaxonProcessor::checkForExceptionCPP(JNIEnv *env, jclass callingClass, jobject callingObject) {
96
SaxonApiException * SaxonProcessor::checkForExceptionCPP(JNIEnv *env, jclass callingClass, jobject callingObject) {
77 97

  
78 98
    if (env->ExceptionCheck()) {
79 99
        std::string result1 = "";
......
283 303
    if (versionStr != nullptr) {
284 304
        delete versionStr;
285 305
    }
306
    exceptionClear();
286 307
}
287 308

  
288 309

  
......
334 355
        SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(saxonCAPIClass, mIDappConfig, proc, stringArray1,
335 356
                                                                 stringArray2);
336 357
        if (exceptionOccurred()) {
337
            exception = checkAndCreateException(saxonCAPIClass);
338
            exceptionClear();
358
            createException();
339 359
        }
340 360
        SaxonProcessor::sxn_environ->env->DeleteLocalRef(stringArray1);
341 361
        SaxonProcessor::sxn_environ->env->DeleteLocalRef(stringArray2);
......
630 650

  
631 651

  
632 652
    if (!proc) {
633
        exception = new SaxonApiException("Processor is null in SaxonProcessor.setCatalog");
653
        createException("Processor is null in SaxonProcessor.setCatalog");
634 654
        return;
635 655
    }
636 656

  
......
660 680
    }
661 681
//TODO SchemaValidator
662 682

  
683
    if(source == nullptr) {
684
        createException("Source string is NULL");
685
        return nullptr;
686
    }
687

  
663 688
    jobject xdmNodei = SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(saxonCAPIClass, mID,
664 689
                                                                                SaxonProcessor::sxn_environ->env->NewStringUTF(
665 690
                                                                                        cwd.c_str()), proc, nullptr,
......
669 694
        XdmNode *value = new XdmNode(xdmNodei);
670 695
        return value;
671 696
    } else if (exceptionOccurred()) {
672
        exception = checkAndCreateException(saxonCAPIClass);
673
        exceptionClear();
697
        createException();
674 698
    }
675 699

  
676 700
#ifdef DEBUG
......
730 754
                                                                                SaxonProcessor::sxn_environ->env->NewStringUTF(
731 755
                                                                                        source));
732 756
    if (exceptionOccurred()) {
733
        exception = checkAndCreateException(saxonCAPIClass);
734
        exceptionClear();
757
        createException();
735 758

  
736 759
    } else {
737 760

  
......
755 778
                                                                                SaxonProcessor::sxn_environ->env->NewStringUTF(
756 779
                                                                                        source));
757 780
    if (exceptionOccurred()) {
758
        exception = checkAndCreateException(saxonCAPIClass);
781
        createException();
759 782
    } else {
760 783
        XdmNode *value = new XdmNode(xdmNodei);
761 784
        return value;
......
963 986
    }
964 987

  
965 988
    if (exceptionOccurred()) {
966
        exception = checkAndCreateException(saxonCAPIClass);
989
        createException();
967 990
    } else {
968 991
        XdmArray *value = new XdmArray(xdmArrayi);
969 992
        return value;
......
1005 1028
        return nullptr;
1006 1029
    }
1007 1030
    if (exceptionOccurred()) {
1008
        exception = checkAndCreateException(saxonCAPIClass);
1031
        createException();
1009 1032
    } else {
1010 1033
        XdmArray *value = new XdmArray(xdmArrayi);
1011 1034
        return value;
......
1047 1070
        return nullptr;
1048 1071
    }
1049 1072
    if (exceptionOccurred()) {
1050
        exception = checkAndCreateException(saxonCAPIClass);
1073
        createException();
1051 1074
    } else {
1052 1075
        XdmArray *value = new XdmArray(xdmArrayi);
1053 1076
        return value;
......
1089 1112
        return nullptr;
1090 1113
    }
1091 1114
    if (exceptionOccurred()) {
1092
        exception = checkAndCreateException(saxonCAPIClass);
1115
        createException();
1093 1116
    } else {
1094 1117
        XdmArray *value = new XdmArray(xdmArrayi);
1095 1118
        return value;

Also available in: Unified diff