Conversation
source/common/json/json_loader.cc
Outdated
| error.line, error.column)); | ||
| char buffer[4096]; | ||
|
|
||
| FILE* fp = fopen(file_path.c_str(), "r"); |
There was a problem hiding this comment.
You are leaking here. Can you use C++ iostream?
There was a problem hiding this comment.
if not, you can use CSmartPtr and supply fclose not to leak fd.
There was a problem hiding this comment.
Was able to switch to iostream.
source/common/json/json_loader.cc
Outdated
| throw Exception(fmt::format("File:{} doesn't exist.", file_path)); | ||
| } | ||
|
|
||
| rapidjson::FileReadStream fs(fp, buffer, sizeof(buffer)); |
There was a problem hiding this comment.
what is buffer used for here? Why does it have to be specified? Why 4K? Seems odd there is no API to just deal with buffering internally.
There was a problem hiding this comment.
Removed. Switched to using iostream.
source/common/json/json_loader.cc
Outdated
| rapidjson::FileReadStream fs(fp, buffer, sizeof(buffer)); | ||
| if (document_.ParseStream(fs).HasParseError()) { | ||
| throw Exception(fmt::format("Error(offset {}): {}\n", | ||
| static_cast<unsigned>(document_.GetErrorOffset()), |
There was a problem hiding this comment.
What is offset? Does it include line number?
There was a problem hiding this comment.
wondering, why casting to unsigned_int?
source/exe/CMakeLists.txt
Outdated
| target_link_libraries(envoy dl) | ||
|
|
||
| include_directories(SYSTEM ${ENVOY_OPENSSL_INCLUDE_DIR}) | ||
| include_directories(SYSTEM ${ENVOY_RAPIDJSON_INCLUDE_DIR}) |
There was a problem hiding this comment.
Removed. It was due to the initial integration of rapidjson. No longer needed now that rapidjson headers are only in the .cc file.
source/server/CMakeLists.txt
Outdated
| include_directories(${ENVOY_NGHTTP2_INCLUDE_DIR}) | ||
| include_directories(SYSTEM ${ENVOY_OPENSSL_INCLUDE_DIR}) | ||
| include_directories(SYSTEM ${ENVOY_LIGHTSTEP_TRACER_INCLUDE_DIR}) | ||
| include_directories(SYSTEM ${ENVOY_RAPIDJSON_INCLUDE_DIR}) |
There was a problem hiding this comment.
It made the compiler happy, back when I was playing with it. I don't think this will be necessary once I find a way to get rid of the refernce to rapidjson/document.h in the json_loader.h
source/common/json/json_loader.h
Outdated
|
|
||
| protected: | ||
| Object() : name_("root") {} | ||
| Object() : name_("root"), document_() {} |
There was a problem hiding this comment.
default initializer not needed
source/common/json/json_loader.h
Outdated
| } | ||
|
|
||
| // Empty Object | ||
| Object(const std::string& name) : name_(name), document_() {} |
There was a problem hiding this comment.
default initializer not needed
source/common/json/json_loader.h
Outdated
| class Object { | ||
| public: | ||
| Object(json_t* json, const std::string& name) : json_(json), name_(name) {} | ||
| Object(const rapidjson::Value& value, const std::string& name) : name_(name), document_() { |
There was a problem hiding this comment.
default initializer not needed
source/common/json/json_loader.h
Outdated
| struct json_t; | ||
| #pragma GCC diagnostic push | ||
| #pragma GCC diagnostic ignored "-Wold-style-cast" | ||
| #include "rapidjson/document.h" |
There was a problem hiding this comment.
Do not leak this in header. Find a way around this even if you need to expose an interface.
source/common/json/json_loader.cc
Outdated
|
|
||
| bool Object::hasObject(const std::string& name) const { | ||
| return json_object_get(json_, name.c_str()) != nullptr; | ||
| return document_.HasMember(name.c_str()) && document_.IsObject(); |
There was a problem hiding this comment.
Don't know API but seems wrong to be calling document_.IsObject() here.
source/common/json/json_loader.cc
Outdated
| double Object::getDouble(const std::string& name) const { | ||
| json_t* real = json_object_get(json_, name.c_str()); | ||
| if (!real || !json_is_real(real)) { | ||
| if (!document_.HasMember(name.c_str()) || !document_[name.c_str()].IsDouble()) { |
There was a problem hiding this comment.
can you avoid multiple hash lookups here and elsewhere
There was a problem hiding this comment.
Removed multiple hash lookups.
source/common/json/json_loader.cc
Outdated
| #pragma GCC diagnostic push | ||
| #pragma GCC diagnostic ignored "-Wold-style-cast" | ||
| #include "jansson.h" | ||
| #include <rapidjson/error/en.h> |
b92feb0 to
bac2199
Compare
include/envoy/json/json_object.h
Outdated
source/common/json/json_loader.cc
Outdated
There was a problem hiding this comment.
nit, i'd reserve vector capacity upfront as we know the Size.
There was a problem hiding this comment.
Fixed here and in json_loader.h
source/common/json/json_loader.cc
Outdated
There was a problem hiding this comment.
not to familiar with api, but can we
- auto &blah = document_[name.c_str()];
and query internal map or something once.
if (!blah.IsBool()) {
}
return blah.GetBool();
docs/install/requirements.rst
Outdated
There was a problem hiding this comment.
delete all references to jansson from docs, cmake, etc.
There was a problem hiding this comment.
I will do that clean up in Jira 615.
include/envoy/json/json_object.h
Outdated
include/envoy/json/json_object.h
Outdated
include/envoy/json/json_object.h
Outdated
include/envoy/json/json_object.h
Outdated
There was a problem hiding this comment.
wrong type / please fix grammar
include/envoy/json/json_object.h
Outdated
There was a problem hiding this comment.
can't this be implemented in terms of iterate? Why is this needed?
There was a problem hiding this comment.
Or get rid of iterate() from the public interface
source/common/json/json_loader.cc
Outdated
There was a problem hiding this comment.
We should not be copying anything. If needed a reference to the parent document should be used.
source/common/json/json_loader.cc
Outdated
test/common/json/json_loader_test.cc
Outdated
There was a problem hiding this comment.
what was this test testing and why is it no longer failing
There was a problem hiding this comment.
This was testing Max and Min Integer. Unfortunately, rapidjson doesn't throw an exception during Parsing. We should push this validation to the schema. :(
source/common/json/json_loader.h
Outdated
source/common/json/json_loader.h
Outdated
source/common/json/json_loader.h
Outdated
There was a problem hiding this comment.
reserve capacity ahead of time
source/common/json/json_loader.h
Outdated
There was a problem hiding this comment.
removed extra local var.
source/common/json/json_loader.h
Outdated
source/common/json/json_loader.h
Outdated
source/common/json/json_loader.cc
Outdated
f311925 to
424f6db
Compare
source/common/json/json_loader.h
Outdated
| struct json_t; | ||
|
|
||
| namespace Json { | ||
| class Object; |
There was a problem hiding this comment.
split object out into public include and only define the factory stuff in this file.
| } | ||
|
|
||
| { | ||
| EXPECT_THROW(StringLoader("{\"val\":9223372036854775808}"), Exception); |
There was a problem hiding this comment.
What actually happens here? We shouldn't delete this test.
* worker: provide removeFilterChain interface (envoyproxy#10528) Signed-off-by: Yuchen Dai <silentdai@gmail.com> * cherry-pick in place filter chain update Signed-off-by: Yuchen Dai <silentdai@gmail.com> * fix conficts Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Jose Nino jnino@lyft.com Description: previously the CI runs would only build the demos. However we did not run them, or check for liveliness. This PR adds running all the Android demos in the emulator for Mac CI. Risk Level: low - improved CI Testing: tested locally and on CI Fixes #117 Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: Jose Nino jnino@lyft.com Description: previously the CI runs would only build the demos. However we did not run them, or check for liveliness. This PR adds running all the Android demos in the emulator for Mac CI. Risk Level: low - improved CI Testing: tested locally and on CI Fixes #117 Signed-off-by: JP Simard <jp@jpsim.com>
Co-authored-by: Matteo Pace <pace.matteo96@gmail.com>
**Commit Message**: This refactors translator by removing the unnecessary reflect as well as the slice variable copies. Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
No description provided.