Skip to content

Commit

Permalink
[AD-638] update logging
Browse files Browse the repository at this point in the history
  • Loading branch information
alinaliBQ committed Mar 15, 2022
1 parent 9438c45 commit a5a1f7c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/odbc/include/ignite/odbc/common/concurrent.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <cassert>
#include <utility>
#include <iostream>

#include "ignite/odbc/common/concurrent_os.h"

Expand Down Expand Up @@ -260,7 +261,7 @@ class IGNITE_IMPORT_EXPORT SharedPointer {
*
* @return Raw pointer.
*/
T* Get() {
T* Get() { //std::cout << "concurrent get()- line 263 called\n";
return ptr;
}

Expand Down
4 changes: 2 additions & 2 deletions src/odbc/src/jni/documentdb_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace jni {
JniErrorCode DocumentDbConnection::Open(const Configuration& config,
JniErrorInfo& errInfo) {
bool connected = false;
std::cout << "Open - line 33 pass\n"; // std::cout << "_jniContext ptr: %p \n" << _jniContext.ptr; std::cout << "_jniContext ptr.jvm: %p \n" << _jniContext.ptr.jvm;
std::cout << "Open - line 33 pass\n"; std::cout << "_jniContext.ptr: " << _jniContext.Get() << "\n"; // std::cout << "_jniContext ptr: %p \n" << _jniContext.ptr; std::cout << "_jniContext ptr.jvm: %p \n" << _jniContext.ptr.jvm;
if (!_jniContext.IsValid()) { std::cout << "Open - line 35 pass\n"; // if (true) { std::cout << "Open - line 35 pass\n"; // if (false) {
errInfo.errMsg = new char[]{"Unable to get initialized JVM."};
errInfo.code = JniErrorCode::IGNITE_JNI_ERR_JVM_INIT; std::cout << "Open - line 37 pass\n";
Expand Down Expand Up @@ -69,7 +69,7 @@ JniErrorCode DocumentDbConnection::Close(JniErrorInfo& errInfo) {
return JniErrorCode::IGNITE_JNI_ERR_SUCCESS;
}

DocumentDbConnection::~DocumentDbConnection() {
DocumentDbConnection::~DocumentDbConnection() { std::cout << "~DocumentDbConnection is called.\n";
if (_jniContext.Get() != nullptr) {
JniErrorInfo errInfo;
Close(errInfo);
Expand Down
17 changes: 9 additions & 8 deletions src/odbc/src/jni/java.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <stdexcept>
#include <string>
#include <vector>
#include <iostream>

using namespace ignite::odbc::common::concurrent;
using namespace ignite::odbc::jni::java;
Expand Down Expand Up @@ -795,18 +796,18 @@ void JniContext::Detach() {

JniErrorCode JniContext::DriverManagerGetConnection(
const char* connectionString, SharedPointer< GlobalJObject >& connection,
JniErrorInfo& errInfo) {
JNIEnv* env = Attach();
jstring jConnectionString = env->NewStringUTF(connectionString);
JniErrorInfo& errInfo) { std::cout << "DriverManagerGetConnection - line 798 pass\n";
JNIEnv* env = Attach(); std::cout << "DriverManagerGetConnection - line 800 pass\n";
jstring jConnectionString = env->NewStringUTF(connectionString); std::cout << "DriverManagerGetConnection - jvm: " << jvm << std::endl; std::cout << "DriverManagerGetConnection - jvm->GetMembers().m_DriverManagerGetConnection: " << jvm->GetMembers().m_DriverManagerGetConnection << std::endl; std::cout << "DriverManagerGetConnection - jvm->GetMembers().c_DriverManager: " << jvm->GetMembers().c_DriverManager << std::endl;
jobject result = env->CallStaticObjectMethod(
jvm->GetMembers().c_DriverManager,
jvm->GetMembers().m_DriverManagerGetConnection, jConnectionString);
ExceptionCheck(env, &errInfo);
if (!result || errInfo.code != JniErrorCode::IGNITE_JNI_ERR_SUCCESS) {
jvm->GetMembers().m_DriverManagerGetConnection, jConnectionString); std::cout << "DriverManagerGetConnection - line 802 pass\n"; // the real line that causes errors to occur, jumping _jniContext prevented calling this function
ExceptionCheck(env, &errInfo); std::cout << "DriverManagerGetConnection - line 805 pass\n";
if (!result || errInfo.code != JniErrorCode::IGNITE_JNI_ERR_SUCCESS) { std::cout << "DriverManagerGetConnection - line 806 pass\n";
connection = nullptr;
return errInfo.code;
}
connection = new GlobalJObject(env, env->NewGlobalRef(result));
} std::cout << "DriverManagerGetConnection - line 808 pass\n";
connection = new GlobalJObject(env, env->NewGlobalRef(result)); std::cout << "DriverManagerGetConnection - line 809 pass\n";
return errInfo.code;
}

Expand Down
2 changes: 1 addition & 1 deletion src/odbc/src/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Logger::WriteMessage(std::string const& message) {

Logger* Logger::Get() {
const char* envVarName = "IGNITE_ODBC_LOG_PATH";
static Logger logger(getenv(envVarName)); std::cout << "Logger Get - line 61 pass\n";
static Logger logger(getenv(envVarName));
return logger.IsEnabled() ? &logger : 0; // -AL-: this could cause segfault because 0 could be returned.
}
} // namespace odbc
Expand Down

0 comments on commit a5a1f7c

Please sign in to comment.