[
https://issues.apache.org/jira/browse/GEODE-7944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17093619#comment-17093619
]
ASF GitHub Bot commented on GEODE-7944:
---------------------------------------
pivotal-jbarrett commented on a change in pull request #593:
URL: https://github.com/apache/geode-native/pull/593#discussion_r415897067
##########
File path: cppcache/test/QueueConnectionRequestTest.cpp
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <QueueConnectionRequest.hpp>
+
+#include <boost/process/environment.hpp>
+
+#include <gtest/gtest.h>
+
+#include <geode/DataOutput.hpp>
+
+#include "ByteArrayFixture.hpp"
+#include "DataOutputInternal.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+inline std::string to_hex(const uint8_t* bytes, size_t len) {
+ std::stringstream ss;
+ ss << std::setfill('0') << std::hex;
+ for (size_t i(0); i < len; ++i) {
+ ss << std::setw(2) << static_cast<int>(bytes[i]);
+ }
+ return ss.str();
+}
+
+inline std::string to_hex(const DataOutput& out) {
+ return to_hex(out.getBuffer(), out.getBufferLength());
+}
+
+inline std::string int_to_hex_string(const int value) {
+ char hex[10];
+ sprintf(hex, "%x", value);
+ return std::string(hex);
+}
+
+TEST(QueueConnectionRequestTest, testToData) {
Review comment:
While I love to see another unit test, it seems like there should have
been a failing integration test. Some of the tests are disabled because they
never worked. Perhaps there is one that matches this failure.
##########
File path: cppcache/src/QueueConnectionRequest.cpp
##########
@@ -28,10 +28,10 @@ void QueueConnectionRequest::toData(DataOutput& output)
const {
output.writeString(m_serverGp);
output.write(static_cast<int8_t>(DSCode::FixedIDByte));
output.write(static_cast<int8_t>(DSCode::ClientProxyMembershipId));
- uint32_t buffLen = 0;
- output.writeBytes(reinterpret_cast<uint8_t*>(const_cast<char*>(
- m_membershipID.getDSMemberId(buffLen))),
- buffLen);
+ uint32_t memIdBufferLength = 0;
+ auto memIdBuffer = m_membershipID.getDSMemberId(memIdBufferLength);
Review comment:
```c++
const auto& dsMemberId = m_membershipID.getDSMemberId();
output.writeBytes(reinterpret_cast<const int8_t*>(dsMemberId.c_str()),
dsMemberId.size());
```
##########
File path: cppcache/src/QueueConnectionRequest.cpp
##########
@@ -28,10 +28,10 @@ void QueueConnectionRequest::toData(DataOutput& output)
const {
output.writeString(m_serverGp);
output.write(static_cast<int8_t>(DSCode::FixedIDByte));
output.write(static_cast<int8_t>(DSCode::ClientProxyMembershipId));
- uint32_t buffLen = 0;
- output.writeBytes(reinterpret_cast<uint8_t*>(const_cast<char*>(
- m_membershipID.getDSMemberId(buffLen))),
- buffLen);
+ uint32_t memIdBufferLength = 0;
+ auto memIdBuffer = m_membershipID.getDSMemberId(memIdBufferLength);
Review comment:
Internally the member ID is a std::string. This method is breaking it
into a c-string and length. Why not just modify the method to return a `const
std::string&`, you get the string and length encapsulated.
##########
File path: cppcache/src/QueueConnectionRequest.cpp
##########
@@ -28,10 +28,10 @@ void QueueConnectionRequest::toData(DataOutput& output)
const {
output.writeString(m_serverGp);
output.write(static_cast<int8_t>(DSCode::FixedIDByte));
output.write(static_cast<int8_t>(DSCode::ClientProxyMembershipId));
- uint32_t buffLen = 0;
- output.writeBytes(reinterpret_cast<uint8_t*>(const_cast<char*>(
- m_membershipID.getDSMemberId(buffLen))),
- buffLen);
+ uint32_t memIdBufferLength = 0;
+ auto memIdBuffer = m_membershipID.getDSMemberId(memIdBufferLength);
Review comment:
The use of `writeBytes` seems suspicious. Have you double checked the
Java side for who it writes and reads this string? There are only about 7 ways
we encode strings. ;)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Unable to deserialize membership id java.io.EOFException on locator only when
> debug is enabled and native client is used
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: GEODE-7944
> URL: https://issues.apache.org/jira/browse/GEODE-7944
> Project: Geode
> Issue Type: Bug
> Components: native client
> Reporter: Jakov Varenina
> Assignee: Jakov Varenina
> Priority: Major
> Attachments: locator.log, native_client.log
>
>
> During the creation of pool in geode native with subscription "enabled"
> exception java.io.EOFException is thrown on locator only when it is
> configured with _--log-level=debug_. On geode native this reflects with "No
> locators available". You can find native_client.log and locator.log in
> attachment.
> Native client code:
> {code:java}
> auto cache = cacheFactory.create();
> auto poolFactory = cache.getPoolManager().createFactory();
> auto pool = poolFactory.addLocator("localhost", 10334)
> .setSubscriptionEnabled(true)
> .create("pool");
> {code}
> With java client everything works OK.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)